我想从数据流中的现有字段动态创建一个变量(不是新字段),然后修改该变量。原因是,我需要在 Sql 语句的子句中使用的字符串列表周围加上
单引号。Kettle 消除了字段中的单引号,但它们保留在变量中。我最好的猜测是在修改后的 Java 脚本中使用 setVariable,但从那里我被难住了。'
IN
1 回答
I must not have enough rep to attach files to answers. Too bad because I have a ktr that does this nicely.
I first add the "'" as a new field to the rows. I then pass the rows with the values I want to transform into a list into a Group By step. I choose an aggregate of 'Concatenate strings separated by' and use a value of ','
, and give the result a new name like 'list'.
Then I pass that result row to a Calculator step where the calculation is A + B + C. I specify the "'" field for values A and C and the list field for value B. Then I pass that result to a Set Variables step.
In the parent job I get a variable that looks just as you would expect: 'val1','val2','val3'
. No JavaScript needed.