【问题标题】:Setting a context variable from a count sql statement从 count sql 语句设置上下文变量
【发布时间】:2016-03-03 13:12:52
【问题描述】:

我是 Talend 新手,感谢任何帮助。我有一个带有语句的 mysql 输入 (tMSSqlInput):select count(*) as row_count from app.ImportFile a where 1;

我想做的事:在数据库中选择计数语句并分配给变量。

这看起来是否适合设置上下文变量:

tMSSqlInput ----> if 语句(不知道这里包含什么)---->tSetGlobalVar

我已阅读:Setting a database value to context variable in talendHow to set context variable from database 但它们是关于带有列名的 select 语句的 SQL 语句。

谢谢大家。

【问题讨论】:

    标签: sql integration talend data-management


    【解决方案1】:

    我更喜欢使用tSetGlobalVar 而不是tJavaRow。这使您更清楚地知道您正在尝试做什么:使用来自 tMSSQLInput 的输入设置一个全局变量。

    tMSSQLInput---main--->tSetGlobalVar
    

    tSetGlobalVar的第一列,添加你想要的全局映射变量的名称,例如“rowCount”

    tSetGlobalVar 的第二列中,输入 rown.count,其中“rown”是来自 tMSSQLInput 的行的名称,“count”是在 tMSQLInput 架构中指定的字段的名称。

    【讨论】:

      【解决方案2】:
      what you can do is below
      tMSSqlInput-->tJavaRow (here you can populate your global variable...lets say your schema column name was row_count then here you can put logic as 
      globalMap.put("row_count_received",input_row.row_count);
      and then you can use if conditional subjob trigger
      
      tMSSQLInput--->tJavaRow
      |
      |if condition ---  (((Integer)globalMap.get("row_count_receive"))==1
      V
      do your operation
      
      similarly you can fork another if statement and where count=0 like above..
      

      【讨论】:

      • 感谢回答,补充:globalMap.put("row_count_received",row3.row_count); System.out.println("测试:"+row3.row_count);但打印出来的是 -> test: null
      • 什么是第 3 行...您可以显示您的工作的帖子图片吗...也可以在 tJavaRow 中使用 input_row.row_count...input_row 是您可以在 tJavarow 中使用的内容,无论传入连接是什么名字。
      猜你喜欢
      • 1970-01-01
      • 2020-11-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-15
      • 2021-02-02
      • 2021-09-14
      相关资源
      最近更新 更多