Page 1 of 1

Is there a sleep functionality in DataStage

Posted: Tue Feb 09, 2010 3:16 pm
by dganeshm
I want to send rows to a Web Service transformer in a controlled format , is there a sleep functionality in DataStage Server Jobs...

Re: Is there a sleep functionality in DataStage

Posted: Tue Feb 09, 2010 3:22 pm
by dganeshm
For example, if the number of rows has reached 500 , create a 2 minute delay and then start processing the next set of 500 and then a 2 minute delay and so on..

Posted: Tue Feb 09, 2010 3:24 pm
by ray.wurlod
Yes, several.

There is a SLEEP command (argument in seconds or as HH:MM (24 hour clock)).

There are statements SLEEP (argument in seconds) and NAP (argument in milliseconds) that you can use in a server routine.

You have access to the operating system sleep command by various means.

Posted: Tue Feb 09, 2010 3:38 pm
by dganeshm
Where can I use the sleep command , i dont see it in the transformer.., I have not created a routine , can you please help me.

Posted: Tue Feb 09, 2010 3:50 pm
by ray.wurlod
Commands can not be executed from the Transformer. If you need to sleep while in a Transformer then you need a Routine that the Transformer stage can call.

Code: Select all

FUNCTION Doze(aInterval)
Perform "SLEEP " : aInterval
Ans = 0
RETURN(Ans)

Posted: Tue Feb 09, 2010 3:58 pm
by dganeshm
I tried this :
FUNCTION DELAY(Arg1)
SLEEP Arg1
PRINT 'STARTING DELAY'
EXECUTE 'CS'
PRINT 'DELAY COMPLETE'
Ans = 1

and it worked, but yours is much more understandable, I will do it your way..

Posted: Tue Feb 09, 2010 7:27 pm
by ray.wurlod
Even better is to leave out the Perform statement.

Code: Select all

FUNCTION Doze(aInterval) 
SLEEP aInterval 
Ans = 0 
RETURN(Ans)

Posted: Tue Feb 09, 2010 10:54 pm
by ray.wurlod
Or, for the truly paranoid function developer.

Code: Select all

FUNCTION Doze(aInterval) 
Begin Case
   Case UnAssigned(aInterval) Or IsNull(aInterval)
      NULL  ; * do nothing
   Case Not(Num(aInterval))
      NULL  ; * do nothing
   Case aInterval <= 0
      NULL  ; * do nothing
   Case @TRUE
      * We have a positive number as the argument
      SLEEP aInterval 
End Case
Ans = 0 
RETURN(Ans)
Add generation of warnings, etc., to your heart's desire!

Posted: Tue Feb 09, 2010 10:57 pm
by dganeshm
Thanks a lot Ray..

Posted: Tue May 29, 2012 1:06 pm
by scooper1004
Is there a way to do this in a parallel job?



Moderator: I corrected your post, you can't put your reply in the subject line, no-one will see it unless they take the time to actually form a reply and notice it there. FYI.

Posted: Thu Jun 21, 2012 9:40 pm
by U
Welcome aboard.

The same technique can be used in a parallel job, but using a parallel routine (and therefore C++ code).

In a parallel job you might also use a BASIC Transformer stage which can invoke server routines such as that described above.

Posted: Wed Jun 27, 2012 1:04 pm
by rameshrr3
Going out of topic here( realized this forum is server jobs only ) , but will an unix sleep in an external filter stage work ? if it does not alter the rest of data ?

Posted: Wed Jun 27, 2012 5:26 pm
by ray.wurlod
No, because the External Filter stage has to do something with the data on its input link and generate data onto its output link. You could possibly add another command in the pipeline, for example

Code: Select all

sleep 30 && cat -