One Star

global variable in tLoop

Hi,
I use Talend 3.0.2 + java.
I declare "start=1" with tSetGlobalVar and I would like to start my tLoop with i=start.
I put "int i="((Integer)globalMap.get("start")) in tLoop declaration but I receive error in code: Start cannot be resolved.
It is a little weird because I use it in some components later and error doesn't occur.
Could anyone tell me what I am doing wrong, please?
Thanks in advance.
Kind regards,
Marcin K.
13 REPLIES
Six Stars

Re: global variable in tLoop

Try
int i=Integer.parseInt(globalMap.get("start"));
Community Manager

Re: global variable in tLoop

Hello
It was a 5871 and I have fixed it.
Please update the change and restart TOS.
Then, set the declaration expression like this:
"int i=Integer.parseInt((String)globalMap.get("start"))"
Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: global variable in tLoop

jholman - thanks for your answer, it still brings an error message: Start cannot be resolved.
shong - thank you too, I try to update but I get error message from Eclipse:
Network connection problems encountered during search.
Unable to access "http://talendforge.org/core/updatesite/3.0/testing/".
Error parsing site stream.
White spaces are required between publicId and systemId.
Error parsing site stream.
White spaces are required between publicId and systemId.
Shong, Any fix for this?
One Star

Re: global variable in tLoop

Hi Shong,
I downloaded latest TOS from SVN - I copied http://talendforge.org/svn/tos/trunk into features directory and restarted TOS but it looks like problem still occurs.
I am attaching 2 screenshots: tSetGlobalVar + settinngs and tLoop + error message.
Any idea how what I do wrong?
Kind regards,
Marcin K.
One Star

Re: global variable in tLoop

Shong,
I successfully updated talend from SVN repository.
I uploaded files into features directory instead of plugins which was wrong.
I get different error message now:
Exception in component tLoop_1
java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
One Star

Re: global variable in tLoop

Some more info: it looks like I can't access any variables set with tSetGlobalVar using (String)globalMap.get("start") which also causes a problem with updated tLoop component.
Strange because it worked before.
Community Manager

Re: global variable in tLoop

Hello
I have committed the update file on trunk:20689, you can go to http://talendforge.org/trac/tos/changeset/20689 and download the new files to your local machine.(see screenshot) Then, copy the two new files: tLoop_begin.javajet and tLoop_end.javaject, go to \plugins\org.talend.designer.components.localprovider_3.0.2.r20205\components\tLoop located on your install folder and paste them, restart TOS.
Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: global variable in tLoop

Hi Shong,
it works fantastic!
Thank you very much for your help and fix.
For people who will take a look here in the future: I use "int i=((Integer)globalMap.get("start"))" in tLoop fields.
Kind regards,
Marcin K.
One Star

Re: global variable in tLoop

Hi,
I wanted to do incremental extraction using global variables. Can anyone please help me out
Moderator

Re: global variable in tLoop

Hi, pramodh
Could you please open a new topic for your job requirement? In addition that, please give us more description about your requirement.
Elaborating your case with an example with input and expected output values will be preferred.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: global variable in tLoop

Hi ,
To accomplish my task i can use either global variable concept or context variables. So explain me the both concepts
My task is to extract the records from a table which is having inserted date greater then the value stored in the global variable/context variable.
for example consider customer table having
txn_id number
cid varchar
pid varchar
saledate timestamp
upon each run of talend job the max(saledate) must be stored in the global variable /context variable and i have use that max(saledate) in the query as
"select * from customer where saledate>"
One Star

Re: global variable in tLoop

Hi,
How can pass my tjava component variable to tmap which means i have to access the variable which is in tjava to tmap. can any one one help me
Seventeen Stars

Re: global variable in tLoop

hi all,
please, as Sabrina 's asked, open new topic for your own purpose & request ?
regards
laurent