0

I wish to use a database column value in the output file name. example: select max(id) from process; suppose the result of above query is 111 -- wish to use this value in the output file name as shown below.

output file name: file_111

how can i achieve this in pentaho kettle? Please advice.

Akn
  • 35
  • 6
  • According to my experience It is not possible. – Helping Hand.. Feb 29 '16 at 08:48
  • As mentioned by Dirk below, i also used the Accept file name from field option in the file output step and used a variable in that name to substitute the value. But i missed proper scope definition of variable in 'set variable Step'. – Akn Feb 29 '16 at 11:11

2 Answers2

1

Please follow the below steps:

Step 1: Table input :- select max(id) as max_id from process;

step 2: Modified Java Script Value:- put bellow code in this step.

eg:- var dummy= 'C:/Users/Venkatesh/Desktop/file_'+ max_id ;

in same step in the bottom ADD Field Name is dummy, Type is string and Replace value 'Fieldname' or 'Rename to' is N

step 3: Text file output:-

    select the **Add filenames to result**
    **file name field** => dummy

Finally execute and see the result..

Venkatesh Panabaka
  • 2,064
  • 4
  • 19
  • 27
1

Depending on the type of file you want to create, you can simply create a column in your stream that contains the file name and then use the Accept file name from field-function that some output steps provide. The text file output for example does have this function, the XML output unfortunately doesn't.

to create the file name itself you can e.g. use the javascript step, or use the concat fields step together with the Add constants step.

Dirk Trilsbeek
  • 5,873
  • 2
  • 25
  • 23