Loop Activity on Time interval

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
anu123
Premium Member
Premium Member
Posts: 143
Joined: Sun Feb 05, 2006 1:05 pm
Location: Columbus, OH, USA

Loop Activity on Time interval

Post by anu123 »

I know loop activity has numeric and list loops. Is there a way to define a time based loop? I want to run my job until it produces a specific value.

For example,

I want to check row count in a table and if it is 0 I want to rerun the job after 5 minutes.
Or
I want to query a DB catalog to see if certain Mview has been refreshed and is ready for downstream processes.

Appreciate your help.

Thank
Anu.
Thank you,
Anu
asorrell
Posts: 1707
Joined: Fri Apr 04, 2003 2:00 pm
Location: Colleyville, Texas

Post by asorrell »

You can accomplish this in a job sequence.

Code: Select all

StartLoop -> Job#1 -> N. Condition (Not ok) -> ExCmd Sleep -> EndLoop
                                       (ok) -> Job#2
Write a Server Job to test for the database condition you are looking for and output a Go / No Go message to the UserStatus variable. You can test for that in a nested condition and decide to either go sleep and repeat the loop or execute Job #2.

I've never done it, but I believe using a Sequencer you could funnel Job#2 back into the "loop" prior to the EndLoop so you could continue the "Test / Sleep / Execute" cycle.
Last edited by asorrell on Wed Sep 18, 2013 9:25 am, edited 2 times in total.
Andy Sorrell
Certified DataStage Consultant
IBM Analytics Champion 2009 - 2020
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

So answer is no, at least not directly. I've done "time based" loops by setting a duration for each loop and then looping how ever many times it would take for that number of loops to hit my end time. You can also use a custom routine to check the current time inside the loop and exit (branch outside the End Loop stage) when your time limit has passed.

For example, your first problem could be solved by looping until the condition is met and then using a routine to "sleep 5" before the next step that runs the job. Condition not met? Branch around the Routine and Job Activity stages inside the loop.

All kinds of ways to skin this cat. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
anu123
Premium Member
Premium Member
Posts: 143
Joined: Sun Feb 05, 2006 1:05 pm
Location: Columbus, OH, USA

Post by anu123 »

Thank you Andy and Craig.
Thank you,
Anu
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

asorrell wrote:I've never done it, but I believe using a Sequencer you could funnel Job#2 back into the "loop" prior to the EndLoop so you could continue the "Test / Sleep / Execute" cycle.
I have and yes you can via a Sequencer set to 'Any'.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply