Using While Loop and subjob with SqlRequest

Highlighted
Four Stars

Using While Loop and subjob with SqlRequest

Hi everyone !

 

I have a problem with inserting a while loop that would contain a Subjob of data extraction.

My query retrieves records between two dates. I have to add 10 days to a date if my request does not return any records. You have to be able to do it X times before getting out of the loop. If at least one record is returned, I leave the loop.

The idea is to do:

int i;
while (i = 0; i <4; i ++)
{
     \\\\\\\\\\\\\\\subjob//////////////

      int nbRow = ((Integer) globalMap.get ("tOracleOutput_2_NB_LINE")). intValue ();

      if (nbRow! = 0)
         break;
      else {
               context.DateMax= TalendDate.addDate (context.sDateMax, 10, "dd");
               context.sDateMax= TalendDate.formatDateLocale ("dd-MMM-yyyy hh: mm: ss", context.sDateMax, "EN");
      }
}

 

Here is my subjob:


While.PNG

Obviously, it doesn't work so...did anyone know how to do this?

 

Thanks for your time !!

 

 

 

Accepted Solutions
Ten Stars

Re: Using While Loop and subjob with SqlRequest

The while loop in your Java component will execute in its entirety before moving on to the next subjob.  If you want to control execution of other components, you can use the tLoop component.  Set the Condition setting to a globalMap boolean variable containing false.  A Java component inside the loop can check the conditions and set the globalMap variable to true when you want the loop to end.

View solution in original post


All Replies
Ten Stars

Re: Using While Loop and subjob with SqlRequest

The while loop in your Java component will execute in its entirety before moving on to the next subjob.  If you want to control execution of other components, you can use the tLoop component.  Set the Condition setting to a globalMap boolean variable containing false.  A Java component inside the loop can check the conditions and set the globalMap variable to true when you want the loop to end.

View solution in original post

Four Stars

Re: Using While Loop and subjob with SqlRequest

Thanks for your quick answer. It works great !

 

 

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog