简体   繁体   中英

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:

  1. ID, name
  2. ID, name
  3. .., ...
  4. ID, name

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}

or better:

select id, name, date, nightmare from table where id in ${ID} and name in ${name}

Note: - ${..} -> variable - I can't do subquery, each query are in different 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 ; you connect it to a new Table Input where you want to pass these values, for example, in the where clause:

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:

  • each parameter is used only once;
  • and they will be passed in the order in which they arrive;
  • all incoming fields must be used in the query.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM