Hitachi Vantara Pentaho Community Forums
Results 1 to 2 of 2

Thread: Problem with looping job

  1. #1
    Join Date
    Oct 2007

    Exclamation Problem with looping job

    Hi all,

    I'm having a problem concerning assigning values to a variable iin a loop. In short, this is my job layout:

    I have a job with two transformations:

    Transformation 1 (containing two steps):
    - 1) selects all distinct invoice numbers from a table, let's say that the result is number 1 to 10.
    - 2) Copy the rows to result

    Transformation2 (containing four steps, and on job level this transformation has the box "Execute for each row" checked):
    - 1) Get rows from result.
    - 2) Set Variables, where I'm setting the variable INVNUM.
    - 3) Selects some rows from another table using the variable in the WHERE-clause of the SQL-query.
    - 4) Writes the rows to an Excel-file named <value_of_the_variable>.xls

    And finally, here's my problem:

    The job creates 10 Excel-files alright, but in the first lap of the loop, the variable isn't assigned a value, hence the first file produced is empty and literally named ${INVNUM}.xls, and the last file produced is 9.xls instead of 10.xls. So it loops 10 times but the variable is one step wrong all the time.

    I made a workaround where I put a dummy transformation in front of my actual transformation, which loops through the invoice numbers and sets my variable INVNUM. This way, when I proceed to the my transformation, the variable already has the value 10 and hence is able to produce all my files correctly.

    Smells like a bug, but I don't rule out the possibility that I'm doing something wrong ;-)

    If anyone could shine some light on this matter it would be most appreciated.


  2. #2
    Join Date
    May 2006


    Problem 1 is that you can't use variables in the transformation where you defined them in. So your workaround is the good one.

    Furthermore if you're using version 2.5.x they had problems with variables if you're using a hierarchy of jobs.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.