Page 1 of 1

multiple loops in a squence job..

Posted: Mon May 03, 2010 9:38 pm
by jagadam
Hi,

My requirement is to pass two sets of dates(as parameters) into the given sql queries.

I have created two jobs, one for each set of dates.

Iam trying call these two jobs thru a sqeunce job and pass the dates in the loops as list.

Here is my sequence flow.

execute stage1-->UserVariable1-->StartLoop1--->Jobactivity1-->executestage2-->UserVariable2-->Jobactivity2-->Jobactivity3-->Stoploop(1&2).

I want to pass for example two sets of parameters(2009-01-31,2009-02-28)and(Prev_yr_date1,Prev_yr_date2). I want the dates to be picked as "2009-01-31" in first loop "Prev_yr_date"1 in the second loop and run till jobactivity3 and then start again from startloop1 with 2009-02-28 in the first loop(ie jobactivity1) and pre_yr_date2 in the second loop(ie jobactivity2) and run till jobactivity3 and so on...
The issue is for the first comple run its picking the dates correctly (ie "2009-01-31" ,"Prev_yr_date1") but for the second run it picking the dates as "2009-02-28",Prev_yr_date1) ie startloop1 is picking the params fine but startloop2 is picking only the first parm..I could figure out where the prooblem is..

I tried to explain it as best as i can(i know that this is still not clear..but thought will give some idea atleast)
Any thoughts on this would be of grt help.

Thanks

Posted: Mon May 03, 2010 9:51 pm
by chulett
I'm a little lost as to what you want to do. You would use a loop inside a loop if you had something like two lists, say:

A,B,C,D
1,2,3,4

And you wanted to run this "Job3" 16 times, once around the inner loop for each item in the outer loop, like so:

A1,A2,A3,A4,B1,B2,B3,B4,C1 (etc)

However, I get the impression that's not what you're after from your description of the 'problem', that being the inner loop starting over from the beginning each time - exactly what it should be doing. Now, if what you actually want is to run the job four times, like:

A1,B2,C3,D4

You only need one loop and one UserVariable stage, which can track both lists and then you iterate through the linked lists simultaneously. I've got a post here showing how to do that, if that's what you need I'll dig it up.

Dug: viewtopic.php?t=127425

Posted: Mon May 03, 2010 10:21 pm
by ray.wurlod
As I read the question, your outer loop processes a date, and the inner loop uses the outer loop's date as the previous date. Is this a correct reading?

Otherwise it's a single loop with multiple loop index variables which you could combine (as a delimited string) into a single loop index variable and parse when assigning parameter values to particular Job activities.

Posted: Tue May 04, 2010 11:06 am
by jagadam
Hi Craig,

I tried your method and it worked...Thanks!!!

Thanks.

Posted: Tue May 04, 2010 1:15 pm
by chulett
8)