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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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:


0683p000009Ls99.png

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

 

Thanks for your time !!

 

 

 
Labels (2)
1 Solution

Accepted Solutions
cterenzi
Specialist
Specialist

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

2 Replies
cterenzi
Specialist
Specialist

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.

Anonymous
Not applicable
Author

Thanks for your quick answer. It works great !