Home » SQL & PL/SQL » SQL & PL/SQL » to prevent a package from being executed again when it's already running
to prevent a package from being executed again when it's already running [message #39005] Thu, 06 June 2002 02:05 Go to next message
Animesh Kumar
Messages: 1
Registered: June 2002
Junior Member
hi
i am running a pl sql package which takes around 1 hour to execute.
while the package is executing, how can i prevent other users from executing it?
regards
animesh.
Re: to prevent a package from being executed again when it's already running [message #39009 is a reply to message #39005] Thu, 06 June 2002 08:00 Go to previous message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
Create a dummy table and then place a lock on the table.
-- this method requires that you have at least 1 row in the table

BEGIN
   FOR i IN  (SELECT 1 FROM dummy_tab FOR UPDATE NOWAIT)
   LOOP
      EXIT;
   END LOOP;
END;

-- this one doesn't require rows in the table
-- execute immediate is an 8i feature
BEGIN
   EXECUTE IMMEDIATE 'lock table dummy_tab in exclusive mode nowait';
END;
Previous Topic: How to use Word in a From?
Next Topic: Insert into a table from another
Goto Forum:
  


Current Time: Mon Nov 19 03:13:10 CST 2018