Reputation: 659
I need to passing variable from modified java script value and pass it to table input query
If i click preview the output
initator_reference | a | '' |
1 | a | null |
2 | a | null |
3 | a | null |
4 | a | null |
It shouldnt be null but "testing" string on that third field and dont ask me why i put that variable in select, its just for testing before i put it in "where condition=variable"
Upvotes: 1
Views: 10121
Reputation: 659
Well i found the solution myself
The First Step is Modified java script value->set variables
and then get variable->table input(check replace variable in script) and you just need to place "?" to your query (this "?" string is your variable, i dont know if there any other way to call variable)
and as reminder javascript on pentaho is a bit different with real javascript
Upvotes: 1
Reputation: 2195
Table Input supports two different ways of making the SQL dynamic: Variable Substitution and inserting data from an incoming stream.
Variable substitution
This is what you currently have configured in the Table Input: You put ${variable} somewhere and when the step initializes, the value is pasted as text into the SQL.
Because all the steps initialize at the same time in a transformation, your Javascript step has not had time to set the value. In PDI you cannot set and use a variable within the same transformation.
Insert data from step
The second way is used by selecting a source step in the "Insert data from step" option in the Table input. In this mode, the Table Input takes a row from the selected step and inserts fields (in order) into the SQL at question marks (?) you insert. Normally it expects a single row, but you can choose to execute for EACH row.
This way should work for your scenario:
Notes:
Upvotes: 4