Four Stars

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

 

Untitled4.png

 

 

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

Untitled5.png

 

 

 

Regards,

 

Jakson

 

1 REPLY
Forteen Stars

Re: how to looping job with if statement in talend?

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.  

Rilhia Solutions