2

I want to only run the job once, 5 business working days after 15th of a month.

e.g. if 15th falls on a Wednesday then run the job following Wednesday (skip Thurs, Fri, Sat, Sun, Mon, Tues) - 5 working days after.

j_deany
  • 67
  • 10
  • take a look here for help ? https://docs.oracle.com/cd/B19306_01/appdev.102/b14258/d_sched.htm#i1013037 – OldProgrammer Jan 27 '20 at 16:58
  • What about public holidays like Christmas, new year, etc? – Wernfried Domscheit Jan 27 '20 at 18:50
  • @WernfriedDomscheit yes, would preferabbly not like to run the job on UK public holidays... – j_deany Jan 29 '20 at 15:56
  • Have a look at https://stackoverflow.com/questions/41936398/calculate-hours-based-on-business-hours-in-oracle-sql/41937356#41937356 how public holidays can be excluded. repeat_interval would be like `'freq=monthly; byday=MON,TUE,WED,THU,FRI; bymonthday=15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31; ; EXCLUDE=NEW_YEARS_DAY,MARTIN_LUTHER_KING_DAY,WASHINGTONS_BIRTHDAY,MEMORIAL_DAY,INDEPENDENCE_DAY,CHRISTMAS_DAY,SPRING_BREAK'` – Wernfried Domscheit Jan 29 '20 at 16:17

1 Answers1

3

Assume you want to run a procedure called prc_myaction, then consider using

begin
dbms_scheduler.create_job (
   job_name           =>  'job_myaction',
   job_type           =>  'STORED_PROCEDURE',
   job_action         =>  'prc_myaction',
   start_date         =>  systimestamp at time zone 'Europe/Istanbul',
   repeat_interval    =>  'freq=monthly; byday=MON,TUE,WED,THU,FRI; bymonthday=15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31;',
   enabled            =>  true);
end;

where the days beyond the scope are ignored such as the 31st day for the month April.

Barbaros Özhan
  • 59,113
  • 10
  • 31
  • 55
  • Maybe I have slightly worded the question wrong... please refer to my edited description above for better clarity. – j_deany Jan 29 '20 at 16:03