Question:
I have two jobs that I want to execute at the same time,
synchronously, and I need to know how to make the jobs start
simultaneously.
This code did not start the jobs at the same time:
dbms_job.submit(jobno1,'pc;', next_date=>SYSDATE);
dbms_job.submit(jobno2, 'pc2;', next_date=>SYSDATE);
dbms_job.run(jobno1);
dbms_job.run(jobno2);
Answer: Whether you are using dbms_job or dbms_scheduler,
when you submit many jobs at the same time, they will begin to
execute simultaneously, unless you have configured the job scheduler
to asynchronous mode.
See my notes on
manipulating SYSDATE for complex Oracle job scheduling.
The question is how to run ad-hoc jobs simultaneously or
synchronously!
With vanilla SYSDATE, one job will start a few fractions of a second
before the other job!
What you want is to make both jobs wait until the same time.
You might try the next minute and then see if the jobs
start at the exact same time . . .
Try something like the following. I have not tried this code, but
the concept is to add one minute to SYSDATE and then truncate the
date format to minutes only.
Hopefully, something like this will force the jobs to submit at the
same time . . .
next_date=>(SYSDATE,'mm/dd/yyyy hh24:mi')+((SYSDATE,'mm/dd/yyyy
hh24:mi')+1)/24/60
Oracle allows for very complex
date
scheduling arithmetic, and I have complete references and
working examples of submitting Oracle jobs here.
For a complete treatment of job scheduling, see the book "Oracle
Job Scheduling". It has working code examples in the book code
download.