2 Replies Latest reply: Apr 16, 2013 12:45 AM by User392774 RSS

    Schedule on  diffirent  time for weekdays and weekends

    User392774
      Hi,

      I need to schedule some job:
      for weekdays (from Monday to Friday) at 18:00
      for weekends (from Saturday to Sunday) at 13:00

      If it is possible to do that?

      I can schedule it from Monday to Sunday at 18:00 or from Monday to Sunday at 13:00. But my requirements are diffirent






      Thank you
        • 1. Re: Schedule on  diffirent  time for weekdays and weekends
          spajdy
          Yes, you must create two schedules and comine it together
          BEGIN
          dbms_scheduler.create_schedule('sch_1', repeat_interval => 'freq=daily;byday=MON,TUE,WED,THU,FRI;byhour=18;byminute=0;bysecond=0');
          dbms_scheduler.create_schedule('sch_2', repeat_interval => 'freq=daily;byday=SUN,SAT;byhour=13;byminute=0;bysecond=0');
          END; 
          / 
          --test 
          DECLARE
            start_date   TIMESTAMP;
            return_date_after TIMESTAMP;
            next_run_date        TIMESTAMP;
           
          BEGIN
            start_date := SYSDATE;
            return_date_after := start_date;
            FOR i IN 1..20 LOOP
              DBMS_SCHEDULER.EVALUATE_CALENDAR_STRING('sch_1,sch_2',
              start_date, return_date_after, next_run_date);
              DBMS_OUTPUT.PUT_LINE('next_run_date: ' || next_run_date);
              return_date_after := next_run_date;
           END LOOP;
          END;
          /
          an result:
          next_run_date: 16.04.13 18:00:00,000000
          next_run_date: 17.04.13 18:00:00,000000
          next_run_date: 18.04.13 18:00:00,000000
          next_run_date: 19.04.13 18:00:00,000000
          next_run_date: 20.04.13 13:00:00,000000
          next_run_date: 21.04.13 13:00:00,000000
          next_run_date: 22.04.13 18:00:00,000000
          next_run_date: 23.04.13 18:00:00,000000
          next_run_date: 24.04.13 18:00:00,000000
          next_run_date: 25.04.13 18:00:00,000000
          next_run_date: 26.04.13 18:00:00,000000
          next_run_date: 27.04.13 13:00:00,000000
          next_run_date: 28.04.13 13:00:00,000000
          next_run_date: 29.04.13 18:00:00,000000
          next_run_date: 30.04.13 18:00:00,000000
          next_run_date: 01.05.13 18:00:00,000000
          next_run_date: 02.05.13 18:00:00,000000
          next_run_date: 03.05.13 18:00:00,000000
          next_run_date: 04.05.13 13:00:00,000000
          next_run_date: 05.05.13 13:00:00,000000
          • 2. Re: Schedule on  diffirent  time for weekdays and weekends
            User392774
            Thanks,

            Actually I figured on my own maybe 20 minutes ago:

            BEGIN
                 dbms_scheduler.create_schedule('weekdays', repeat_interval => 'FREQ=WEEKLY; BYDAY=MON,TUE,WED,THU,FRI;BYHOUR=18;BYMINUTE=0');
                 dbms_scheduler.create_schedule('weekends', repeat_interval => 'FREQ=WEEKLY; BYDAY=SAT,SUN;BYHOUR=13;BYMINUTE=0');
            dbms_scheduler.create_schedule('general', repeat_interval => 'weekdays,weekends');
            END;

            Edited by: 919758 on 2013.4.15 22.43

            Edited by: 919758 on 2013.4.15 22.44

            Edited by: 919758 on 2013.4.15 22.45