One Star

possible to use tloop with dynamically changed variable for condition

Hi, I am doing a development, which requires to run mulitiple time of a job. I am thinking to use tloop with While clause. However, the requirement is the condition is coming from a variable, which may be changed. I am wondering how to use the condition in tloop while clause. Also I am wondering how to pass a variable to the sql in tPostgresInput.
Thanks,
12 REPLIES
One Star

Re: possible to use tloop with dynamically changed variable for condition

Hi
You might use tContextLoad and load it into a context variable.
For more information, please download the document here and get scenarios about this component.
Regards,
Pedro
One Star

Re: possible to use tloop with dynamically changed variable for condition

Can the condition in tLoop take the conext varaible?
One Star

Re: possible to use tloop with dynamically changed variable for condition

Hi
Yes. Of couse.
Let's say we have added a context variable called context.new1.
You can type it as the following image.
Regards,
Pedro
One Star

Re: possible to use tloop with dynamically changed variable for condition

Hi
you suggested of using tContextLoad, which can load the properties of dbinput. I know how to make it works. My question is to enter variables in the Query, such as:
Select a.id
, a.registration
from comprehensive a
where a.registration_time between (context.time1) and (context.time2).
I would to know how to assign time1 and time2.
Thanks,
One Star

Re: possible to use tloop with dynamically changed variable for condition

Hi
"Select a.id
, a.registration
from comprehensive a
where a.registration_time between "+context.time1+" and "+context.time2

Regards,
Pedro
One Star

Re: possible to use tloop with dynamically changed variable for condition

Thanks a lot. It all works.
One Star

Re: possible to use tloop with dynamically changed variable for condition

Hi pedro,
I have got the sql that using context variables working. But when I tried to use context in tLoop with the context variable assigned to a while loop condition. I got the Exception in component tLoop_1
java.lang.NullPointerException.
I am using:
dbInput->tMap->tContextLoad--(onComponentOk)-->tLoop->tSleep.
I am using key: run_num, value:2 in the tContextLoad. In tLoop, i am using "i<context.run_num" as the condition.
I tried the same assignment with FileList. it works. I don't know why the above one doesn't work.
Any help is very apprecaited.
Thanks,
One Star

Re: possible to use tloop with dynamically changed variable for condition

Hi
Please show me the entire error log.
Maybe the value didn't pass into context vairable by using tContextLoad.
You'd better check it.
Regards,
Pedro
One Star

Re: possible to use tloop with dynamically changed variable for condition

thanks for the quick reply. I found the error. It's a bug in my code. Thanks again.
One Star

Re: possible to use tloop with dynamically changed variable for condition

Hello,
Does anyone knows how to read/parse a db table, for each record load fields in to the context variable, and execute subjob that uses these variables as parameters. Actually main problem is how to read fields from DBtable and store them in context variable. Also, how to save context variable in DBtable.
Thanks in advance
Zoran
One Star

Re: possible to use tloop with dynamically changed variable for condition

Hi
Hello,
Does anyone knows how to read/parse a db table, for each record load fields in to the context variable, and execute subjob that uses these variables as parameters. Actually main problem is how to read fields from DBtable and store them in context variable. Also, how to save context variable in DBtable.
Thanks in advance
Zoran

This is related to 25195.
Rergards,
Pedro
Seventeen Stars

Re: possible to use tloop with dynamically changed variable for condition

hi all,
it could be solution to read each line and iterate the flow to "something" ?
Seems like "for each line read data and do something with them".
TDB_output -> flow to iterate -> tRunJob

use the globalMap instead context var.(don't have to use javarow by that way)
Even if i'm not a fan to pass flow's data with context variable to subJob .
regards
laurent