Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
andrewmo
Creator
Creator

Sleep for 5 minutes then restart load script

Hello

I have a load script that does a date check for last update time of a table. If that update time is NULL or the update time is not today then set variable to 1 else 0. How do script if the variable is 1 Sleep for 5 minutes then restart the load script. Here is the load statement I am using:

CHK:

LOAD Rec;

SQL

with ld as (

select TABLE_NAME, 

DEPENDENT_INI,

EXEC_DESCRIPTOR as EXECUTION,

INITIALIZE_TIME,

END_TIME,

DATEDIFF(mi,INITIALIZE_TIME,END_TIME) as StartToEnd_Mins,

ROWS_INITLY_LOADED,

ROWS_STAGED,

STATUS

from CR_STAT_EXTRACT

where STATUS in ('Success', 'Warning') --Only show loaded tables

and LOAD_POOL is not NULL

and CONVERT(date,INITIALIZE_TIME) = CONVERT(date,GetDate())

and DEPENDENT_INI NOT LIKE 'VR_%'

--and TABLE_NAME = 'ARPB_TRANSACTIONS'

)

SELECT MAX(CONVERT(date,END_TIME)) as Rec

FROM ld;

VAL:

LOAD DISTINCT Rec

,if(IsNull(Rec) OR Date(Rec) <> Date(Today()),1,0) as Fail

RESIDENT CHK;

LET vFail = PEEK('Fail','VAL');

Here is where I would put the Sleep and reload function.

Any help would be greatly appreciated.

Thanks

1 Solution

Accepted Solutions
sunny_talwar

May be like this

IF $(Variable) = 1 then

     SLEEP 300000;

ENDIF;

View solution in original post

4 Replies
sunny_talwar

May be like this

IF $(Variable) = 1 then

     SLEEP 300000;

ENDIF;

andrewmo
Creator
Creator
Author

I believe that will work for creating the 5 minute pause, but how do I script the restart of the initial load? I basically want to keep reloading in 5 minute intervals until the variable is 0.

sunny_talwar

May be using a for loop...

maxgro
MVP
MVP

let vloop=1;

Do while vloop

    sleep 300000;  

     // add your check

     // and set vloop to 0

     // to exit the loop

loop