Hitachi Vantara Pentaho Community Forums
Results 1 to 5 of 5

Thread: Why wont variables update?

  1. #1
    Join Date
    Apr 2017
    Posts
    3

    Default Why wont variables update?

    I can't seem to get variables to change after i initially set them. I have a transform 3-steps: Table input-select values-set variables that gets the row count of a table and set the field and variable to Row_Count and ROWCOUNT. and as a part of this problem i have tried all 4 possible scopes for the variable. I call this transform on a single threader just to get it to run ( there really needs to be a way to call a transform without sending rows for one shot use like i am trying to do) and use a blocking step to wait for it to return. The first time I will get a good number lets say 100 in the variable ROWCOUNT which i plug into an Add Sequence in the form ${ROWCOUNT} as the start value and it works. BUT if i change the record count in the table and run it again ..i will not get the new value but will still be at the old one. I have tried about everything that I can to get that value to update consistently. The funny part is the field Row_Count does change and is always a good value but if there is a way to use a field in the Add Sequence i have not figured it out. I can't set that field to a variable either that doesn't work ..the whole can't use a variable in the same transform thing I guess. This is such a simple little thing and i can not seem to get it to work. """Variables""" in this program are kind of a mess and add a whole level of complexity that in about any other ..I'll say program... are one of the easiest things to use.

    There has to be a easy way to do this, all I'm trying to do is get a count from a table and use that number as the start of a sequence to increment it ..and as i will be using that number in a few transforms i would like to be able to get it when I need it with out having to use those 3 steps every time kind of like a function. also just to mention it ...if i run the row count transform by its self it always updates ROWCOUNT correctly( setting the scope root) but not when called. My understanding of these variables is that if the are called then the are available to the parent when set that way ...so I am clueless of what i am doing wrong.

  2. #2
    Join Date
    Apr 2008
    Posts
    4,696

    Default

    Did you see the nice big warning message after the set variables form saying "You cannot set and use variables in the same transformation"?

    PDI is very multi-threaded. All the steps initialize at the same time, so when the sequence step initializes, the variable hasn't been set yet.
    Last edited by gutlez; 04-12-2017 at 01:12 PM.

  3. #3
    Join Date
    Apr 2017
    Posts
    3

    Default

    Why yes I did, they are not in the same transformation they are being set in another that is being called and that does not explain why it does not change when i do the transform by its self or set the scope to the java machine or if called the parent. It just does not change after it is initially set.

  4. #4
    Join Date
    May 2014
    Posts
    358

    Default

    I have done something similar and it worked for me. I ran a sequence in one transformation, got the latest row, set the last sequential number + 1 to a variable, then used this variable in another transformation to continue the sequence. But these transformations have to be chained in a job. I don't know what are you trying to achieve with single threaders and blocking steps. Are you trying to call a subtransformation? ...maybe I don't want to know.

  5. #5
    Join Date
    Apr 2008
    Posts
    4,696

    Default

    How about you post your transforms and jobs and we'll provide feedback.

    The way I'm reading your first post looks like you're trying to do:
    Incoming Stream -> Single Threader (Calling T2) -> Blocking Step -> Add Sequence -> Additional Steps

    T2: Table Input -> Select Values -> Set Variables

    Note: This setup **WILL NOT WORK* because the Add Sequence Step is initialized *BEFORE* the Single Threader runs.
    Last edited by gutlez; 04-13-2017 at 11:39 AM.

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.