Christopher Poole Oracle Database Consultancy
PL/SQL Tips
Home My CV Applications Tips About
     
 
13 Jan 2005 - Uninterrupted sleep
 

As pointed out by Jonathan Lewis (http://www.jlcomp.demon.co.uk/faq/sleep.html), the well known method for sleeping inside PL/SQL by using DBMS_LOCK.SLEEP suffers from a few bugs!

However, there is another SLEEP procedure, hidden inside the (mostly) undocumented package DBMS_BACKUP_RESTORE. This does exactly what it says on the tin, and as far as I can tell suffers from neither of the two demonstrated bugs.

Now DBMS_BACKUP_RESTORE is created by catproc.sql, so unless the DBA has dropped this package this solution exists on all databases (past 8i at any rate).

But before you go off granting EXECUTE on DBMS_BACKUP_RESTORE to anyone and everyone and emailing all your developers, remember that this package is an API to RMAN functionality, so do the decent DBA thing and wrap it in your own procedure:

CREATE OR REPLACE PROCEDURE sleep (seconds_to_sleep IN INTEGER) IS

BEGIN

SYS.DBMS_BACKUP_RESTORE.SLEEP(seconds_to_sleep);

END;

/


 

 

 
 

 


Copyright © Christopher Poole
25 April 2005
Disclaimer