Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

how to looping job with if statement in talend?

hi all,

 

I'm trying to extract XML data from a website using the tRestClient API, in the first step i am getting value max_page from Mysql database, then it used for URL in tRestClient and the next step parsing the XML with tExtractXMLField and then saved into databases

 

0683p000009LsYH.png

 

 

but i need to repeat my job from first step if tExtractXMLField column status = SUCCESS, and stop when column status = FAILED

0683p000009LsVP.png

 

 

 

Regards,

 

Jakson

 

Labels (5)
5 Replies
Anonymous
Not applicable
Author

You can do this with a tLoop and a globalMap variable. For an example of something similar (similar in that a loop carries on until something in the processing changes) take a look here: https://www.rilhia.com/tutorials/using-talend-get-your-spotify-listening-history-facebook

Look for the section with the heading "The GetMySpotifyListeningHistory Job" and take a look at how that works.

 

Essentially you want to create a globalMap variable to hold your status value. Base the tLoop on the contents of that value (true/false). Pre-set that globalMap with the value true. Base the tLoop logic on the presence of "true" in the globalMap variable. 

 

You can store your success value in the globalMap for every row either using a tJavaFlex or a tSetGlobalvar component.  

sleck75
Contributor
Contributor

Hi,

 

Is the link to the tutorial broken? I can't seem to get it to work.

 

Thanks,

Scott

fdenis
Master
Master

you can just add tLoop and a tDie (linked by an if link) to get out.
Anonymous
Not applicable
Author

Sorry about my site @ssunday. My server was attacked by some Russian hackers (according to their IP addresses anyway) and I had to take it down. Unfortunately I have not been able to find the time to rebuild it. I will get the tutorials back online as soon as I can though.

 

In the meantime, the way to approach this problem is to use a tLoop with a While loop based on a value that can be changed after each loop. In my example I used the While loop's conditional variable to hold the URL I needed the web service to call. Before the tLoop I would set the initial URL and use the tLoop to iterate over service calls. Each time the service was called it would return some XML and if the results required another service call, it would supply another URL. I would extract that from the dataset and add it to the tLoop's conditional variable that the While loop is based on. If there was no URL returned, I would set the conditional variable to null and that would stop the tLoop.

sleck75
Contributor
Contributor

Many thanks @rhall. I'll give it a try and also look out for tutorials coming back online 0683p000009MACn.png

 

Cheers,
Scott