Search code examples
javascriptpentahopentaho-spoon

how to pass a variable from "modified javascript"-step in "sql script"-step in pentaho spoon?


I am new at pentaho spoon. I have written a small javascript, were I have saved a date in a variable. And now I need to use this variable in sql statement in order to delete data from database with this date (everything is done in one transformation). Can someone tell me, if there are the ways, how to pass this variable from "modified javascript"-step in "sql script"-step? Thank you for your help.


Solution

  • Be sure you use your variable in the "Output Fields" section of the Modified Java Script Value step. This will add it as a column in your data flow.

    Then connect this step to an Execute SQL script step. Configure it as in the following image, supplying your own connection name and table name. In this step, I assume you called your field "DateField", and the column in your table is named "datestamp".

    enter image description here

    Note that there are a great many ways to do this. This is one way that works in a transform; there are others that work for jobs too.