[英]Pentaho get variables from table input to use it in sql script
I'm trying to get variables from table input, table input return this data: 我正在尝试从表输入获取变量,表输入返回此数据:
I want to use this data to get other data in a other table input: 我想使用此数据来获取其他表输入中的其他数据:
select id, name, date, nightmare from table where id = ${ID} and name = ${name} 从表中选择ID,名称,日期,噩梦,其中ID = $ {ID},名称= $ {name}
or better: 或更好:
select id, name, date, nightmare from table where id in ${ID} and name in ${name} 从表中选择ID,名称,日期,噩梦,其中$ {ID}中的ID和$ {name}中的名称
Note: - ${..} -> variable - I can't do subquery, each query are in different dbms 注意:-$ {..}->变量-我无法执行子查询,每个查询都位于不同的dbms中
Thanks 谢谢
What you're after aren't variables, which would need to be set before the transformation initialises and are always single values. 您所需要的不是变量,而是在转换初始化之前需要设置的变量,它们始终是单个值。
You're after parameters. 您需要参数。
Your Table input1 returns several rows of data with fields id
and name
; 您的Table input1返回几行数据,其中包含
id
和name
字段; you connect it to a new Table Input where you want to pass these values, for example, in the where clause: 您将其连接到要在其中传递这些值的新表输入,例如,在where子句中:
select * from customers where id = ? and name = ?
The question marks will be replaced by the values coming from the previous step. 问号将替换为上一步中的值。
You just need to fill in the name of the first step in the box "Insert data from Step" and check the "Execute for each row" box. 您只需要在“从步骤插入数据”框中填写第一步的名称,然后选中“为每一行执行”框。
Now your query will run once for each row arriving at that step, and the values will be replaced. 现在,查询将针对到达该步骤的每一行运行一次,并且将替换这些值。
Caveat: 警告:
If you need to use the same parameter multiple times or use them in a different order you'll need to change the structure of your incoming data stream with a Select Values step. 如果需要多次使用相同的参数或以不同的顺序使用它们,则需要使用“选择值”步骤更改传入数据流的结构。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.