天天看點

【Kettle】 kettle 循環執行作業

【Kettle】 kettle 循環執行作業

1.JavaScript 

var prevRow=previous_result.getRows();//擷取上一個傳遞的結果,資料庫中查詢的結果集
if (prevRow == null &&(prevRow.size()=0))
{
    false;

}else{
    parent_job.setVariable("tables", prevRow);//ArrayList存儲表名變量,以數組形式儲存入table1,table2
    parent_job.setVariable("size", prevRow.size());//存儲執行表的總數量
    parent_job.setVariable("i",new Number(0));//循環控制變量
    parent_job.setVariable("k",0);

    parent_job.setVariable("id", prevRow.get(0).getString("hosp","hosp"));//根據字段名擷取值
    parent_job.setVariable("hospname", prevRow.get(0).getString("hospname","hospname"));
      true;
} 

           

2.JavaScript2

var prevRow=previous_result.getRows();
var size = new Number(parent_job.getVariable("size"));
var i = new Number(parent_job.getVariable("i"))+1;

 


if(i<size){
  parent_job.setVariable("id",prevRow.get(i).getString("hosp","hosp"));
  parent_job.setVariable("hospname",prevRow.get(i).getString("hospname","hospname"));
}
parent_job.setVariable("i",i);
 
true;
           

3.循環停止條件,

【Kettle】 kettle 循環執行作業

4.資料庫結果集查詢

【Kettle】 kettle 循環執行作業

繼續閱讀