Waiting for a submitted job to finish in Oracle PL/SQL?
- by vicjugador
I'm looking for the equivalent of Java's thread.join() in PL/SQL. I.e. I want to kick off a number of jobs (threads), and then wait for them to finish.
How is this possible in PL/SQL?
I'm thinking of using dbms_job.submit (I know it's deprecated). dbms_scheduler is also an alternative.
My code:
DECLARE
jobno1 number;
jobno2 number;
BEGIN
dbms_job.submit(jobno1,'begin dbms_lock.sleep(10); dbms_output.put_line(''job 1 exit'');end;');
dbms_job.submit(jobno2,'begin dbms_lock.sleep(10); dbms_output.put_line(''job 2 exit'');end;');
dbms_job.run(jobno1);
dbms_job.run(jobno2);
//Need code to Wait for jobno1 to finish
//Need code to Wait for jobno2 to finish
END;