Page 1 of 1

Loop Activity on Time interval

Posted: Wed Sep 18, 2013 8:35 am
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.

Posted: Wed Sep 18, 2013 9:21 am
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.

Posted: Wed Sep 18, 2013 9:23 am
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:

Posted: Wed Sep 18, 2013 1:11 pm
by anu123
Thank you Andy and Craig.

Posted: Wed Sep 18, 2013 1:45 pm
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'.