// Exe 1-1
this.btn_Exe1_1_onclick = function(obj:nexacro.Button,e:nexacro.ClickEventInfo)
{
var nColCount = this.Dataset1.getColCount(); // this.Dataset1.colcount;
var nRowCount = this.Dataset1.getRowCount(); // this.Dataset1.rowcount;
trace("Col Count=" + nColCount + " : Row Count=" + nRowCount);
this.txtRtn1.set_value("Col Count=" + nColCount + " : Row Count=" + nRowCount);
for(var i=0; i<nColCount; i++){
// var sColID = this.Dataset1.getColID(i);
// trace("Col ID=" + sColID); // output 에 표시
var objCol = this.Dataset1.getColumnInfo(i); // 컬럼 정보 get
trace(objCol.id + " : " + objCol.type + " : ")
}
-- 결과
// Exercise 2 ================================================================
// Exe 2-1 : 단일 조건에 대한 1개의 인덱스만 반환
this.btn_Exe2_1_onclick = function(obj:nexacro.Button,e:nexacro.ClickEventInfo)
{
// var nRow = this.Dataset1.findRow("EMPL_ID", "KR120"); // 인덱스 값을 반환
// var sVal = this.Dataset1.getColumn(nRow, "FULL_NAME"); // 데이터 값 반환
// 두 개의 변수를 lookup 함수를 통해 하나로 줄임
sVal = this.Dataset1.lookup("EMPL_ID","KR120","FULL_NAME"); // lookup( 컬럼명, 데이터, 새 컬럼을 통해서 얻은 FULL_NAME
trace(sVal);
this.txtRtn1.set_value(sVal);
};
// Exe 2-2 : 복합 조건에 대한 1개의 인덱스만 반환
this.btn_Exe2_2_onclick = function(obj:nexacro.Button,e:nexacro.ClickEventInfo)
{
var nRow = this.Dataset1.findRowExpr("DEPT_CODE == 'K10' && SALARY <= 5000"); // Expression 을 활용
var sVal = this.Dataset1.getColumn(nRow, "FULL_NAME");
trace(sVal);
this.txtRtn1.set_value(sVal);
};
// Exe 2-3 : 해당 조건을 만족하는 모든 컬럼 반환
this.btn_Exe2_3_onclick = function(obj:nexacro.Button,e:nexacro.ClickEventInfo)
{
var sText = "";
var arrRow = this.Dataset1.extractRows("DEPT_CODE=='K10'");
for(var i=0; i<arrRow.length; i++){
var sValue = this.Dataset1.getColumn(arrRow[i], "FULL_NAME");
trace(sValue);
sText += sValue + "\n";
}
this.txtRtn1.set_value(sText);
// 2-3 extractRows -> findRow 함수로 변경한다면?
// var nCnt = this.Dataset1.getRowCount(); //iCnt 변수로 건수를 받아서 체크
// for(var i=0;i<nCnt; i++){
// var nRow = this.Dataset1.findRow("DEPT_CODE","K10", i,-1); //<-- startrow, endrow
// if(nRow >= 0){
// i = nRow ;
// trace(nRow + "===" + i + "==" + this.Dataset1.getColumn(i,"FULL_NAME"));
// }
// }
};