Pentaho Data Integration setVariable not working

╄→尐↘猪︶ㄣ 提交于 2019-12-13 02:42:09

问题


I am on PDI 7.0 and have a "Modified Java Script Value" step inside a transformation as below:

var numberOfDays = 100;
Alert(numberOfDays);
setVariable("NUMBER_OF_DAYS", numberOfDays, "r");
Alert(getVariable("NUMBER_OF_DAYS", ""));

However, when I run the transformation, the first Alert correctly throws 100, but the next Alert is blank (meaning the variable is not set).

What is wrong here?


回答1:


As a rule of thumb, you should never set a variable and read it within the same transformation.

See a warning that pops up in Spoon when setting up Set Variables step:

That said, what you could do, if you really insist on setting this via Java Script is the following design:

where

1) Set variable transformation is used to set the value:

var numberOfDays = 100;
Alert(numberOfDays);
setVariable("NUMBER_OF_DAYS", numberOfDays, "r");

2) Get variable transformatoin only reads it

Alert(getVariable("NUMBER_OF_DAYS", ""));

Both transformations use the same steps, but they have separate task.



来源:https://stackoverflow.com/questions/52380779/pentaho-data-integration-setvariable-not-working

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