• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4221
  • Last Modified:

sleep command in plsql

is there sleep command in plsql?
0
wabby26
Asked:
wabby26
  • 2
1 Solution
 
mszacikCommented:
There is a procedure called SLEEP in the SYS.DBMS_LOCK package that you can use.
0
 
psmith789Commented:
Not as such.

You could create a stored procedure that would take as an argument how long you wanted to wait, which would note the SYSDATE value when it started and then ran a WHILE loop until the designated time came.

The date/time manipulation might be a bit tricky (as it often is in Oracle), but this should work.

If this does it for you, please accept the comment as the answer. Otherwise, good luck!
0
 
Mark GeerlingsDatabase AdministratorCommented:
Not directly, but you can use the dbms_pipe package to get the effect.  The receive_message function in that package has a timeout parameter (in seconds I think) so this should give you a 20-second "sleep" time:

declare
  dummy integer;
begin
  dbms_output.put_line('Started at '||to_char(sysdate,'HH24:MI:SS'));
  dummy := dbms_pipe.receive_message('waitpipe',20);
  dbms_output.put_line('Ended at   '||to_char(sysdate,'HH24:MI:SS'));
end;
/

Notes: the "dbms_output.put_line" commands just give you visual confirmation for testing.  Remember to "set serveroutput on" in SQL*Plus first.
0
 
mszacikCommented:
There is a procedure called SLEEP in the SYS.DBMS_LOCK package you can use.  You pass in the seconds you want execution suspended.
0

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now