Execute SQL step in pentaho

我的梦境 提交于 2019-12-25 08:58:06

问题


I have created transformation which includes table input,sql step and excel o/p step. 1)Table input-->Run a query and get the field "query" which includes sql query

"select * from dual"

2)Execute sql step-->Dynamically passing that query field using '?' and enabling variable substitution 3)Excel o/p-Expecting o/p is the sql query should be triggered and get the result in excel o/p

But i can't get the fiels from execute sql step..How i can do this???

Thanks Kavitha S


回答1:


Use Database join instead of Execute SQL step. The Database Join step allows you to run a query against a database using data obtained from previous steps.

  • Database join Input: You can pass any of data you want from previous step using ? notation in SQL query defined inside the step.
  • Database join Output: Executes parametrized SQL query and adds new parameters as an output.

The step is what you need for your 2nd step. See more info about the Database join step in the documentation.




回答2:


In PDI, "Execute SQL Step" is not meant for generating rows. It will not add any extra row to the data stream. You got Table Input step to generate multiple rows.

What you can try as an alternative is to break the transformation into two parts.

Part 1: Table Input Step > (query rows are generated) >> Use "Set variables" or "copy rows to result" to some other steps to set the query into some variable e.g: query.

Part 2: Take another Table Input Step (into a next .ktr file) and use the variable substitution of ${query} >> Finally output the result set to the excel output.

For dynamically sql queries, you can read this blog.


In case you have some lookups to do with the query generated, you can use Dynamic SQL row to generate the rows.

Hope it helps :)



来源:https://stackoverflow.com/questions/28534640/execute-sql-step-in-pentaho

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!