Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle Scheduler – Creating a complex schedule with a single job

I have a Job running on an Oracle 10g DB with a pretty simple execution plan.

BYDAY=MON,TUE,WED,THU,FRI;BYHOUR=6,10,14,18

Now the problem is that we have to change the plan – but just for Mondays. So on Mondays the first job should run at 8 instead of 6. Then like all the others (10, 14, 18). Whereas from Tuesday to Friday it should run as above.

The easiest way would be to create a second job for the Monday and to remove the Monday from the original job. This, however, is a problem for our application, as it relies on just one job per import.

So the question is: Is there a way to tell the scheduler to run at 6,10,14,18 o'clock TUE-FRI and 8,10,14,18 on MON with a single job?

I read about specifying a repeat interval with a PL/SQL expression. But I didn't find out if there is way to do it.

Thanks for your help

like image 946
Phil Avatar asked Dec 14 '25 06:12

Phil


1 Answers

create a composite schedule, and assign that to the job when you create it.

for example:

begin
  dbms_scheduler.create_schedule('MY_SCHED1', repeat_interval =>
  'FREQ=DAILY;BYDAY=TUE,WED,THU,FRI;BYHOUR=6,10,14,18');
END;
/
begin
dbms_scheduler.create_schedule('MY_SCHED2', repeat_interval =>
  'FREQ=DAILY;BYDAY=MON;BYHOUR=8,10,14,18');
END;
/
begin
dbms_scheduler.create_schedule('MAIN', repeat_interval =>
  'MY_SCHED1, MY_SCHED2');
END;
/

now you'd just assign the "MAIN" named schedule to the job instead of the schedule string.

like image 188
DazzaL Avatar answered Dec 16 '25 22:12

DazzaL



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!