kettle循环执行作业中结果集中数据获取

kettle循环执行作业中结果集中数据获取_第1张图片

1.JavaScript 

  1. var prevRow=previous_result.getRows(); //获取上一个传递的结果,数据库中查询的结果集
  2. if (prevRow == null &&(prevRow.size()= 0))
  3. {
  4. false;
  5. } else{
  6. parent_job.setVariable( "tables", prevRow); //ArrayList存储表名变量,以数组形式保存入table1,table2
  7. parent_job.setVariable( "size", prevRow.size()); //存储执行表的总数量
  8. parent_job.setVariable( "i", new Number( 0)); //循环控制变量
  9. parent_job.setVariable( "k", 0);
  10. parent_job.setVariable( "id", prevRow.get( 0).getString( "hosp", "hosp")); //根据字段名获取值
  11. parent_job.setVariable( "hospname", prevRow.get( 0).getString( "hospname", "hospname"));
  12. true;
  13. }
2.JavaScript2

  1. var prevRow=previous_result.getRows();
  2. var size = new Number(parent_job.getVariable( "size"));
  3. var i = new Number(parent_job.getVariable( "i"))+ 1;
  4. if(i
  5. parent_job.setVariable( "id",prevRow.get(i).getString( "hosp", "hosp"));
  6. parent_job.setVariable( "hospname",prevRow.get(i).getString( "hospname", "hospname"));
  7. }
  8. parent_job.setVariable( "i",i);
  9. true;
3.循环停止条件,
kettle循环执行作业中结果集中数据获取_第2张图片

4.数据库结果集查询

kettle循环执行作业中结果集中数据获取_第3张图片


你可能感兴趣的:(kettle循环)