修改 DBMS_SCHEDULER 作业以在特定时间和分钟之间停止 运行

Modify DBMS_SCHEDULER job to stop running between certain hours and minutes

我需要在 23:00PM 到 19:45PM 之间将工作更改为 运行。我已经尝试了下面的方法来实现这个,但是下面的问题是工作总是每小时停止 15 分钟,例如 10:45 到 11:00 等之间。我不确定我是否可以修改以下内容来解决这个问题。

BEGIN

DBMS_SCHEDULER.SET_ATTRIBUTE (
    name => 'MY_TEST_JOB',
    attribute => 'repeat_interval',
    value => 'FREQ=SECONDLY;INTERVAL=5;
              BYHOUR=23,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19;
              BYDAY=mon,tue,wed,thu,fri,sat,sun;
              BYMINUTE=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40'

);

END;

创建两个时间表并将它们合并:

exec DBMS_SCHEDULER.CREATE_SCHEDULE('JOB_PERIOD_1', 
   repeat_interval => 'FREQ=SECONDLY;INTERVAL=5;BYHOUR=23,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18');

exec DBMS_SCHEDULER.CREATE_SCHEDULE('JOB_PERIOD_2', 
   repeat_interval => 'FREQ=SECONDLY;INTERVAL=5;BYHOUR=19;BYMINUTE=0,1,2,3,4,5,[...],43,44');


BEGIN
   DBMS_SCHEDULER.SET_ATTRIBUTE (
      name => 'MY_TEST_JOB',
      attribute => 'repeat_interval',
      value => 'JOB_PERIOD_1,JOB_PERIOD_2'
   );
END;

实际上我只用这个 PL/SQL 块测试了它。

DECLARE
   next_run_date TIMESTAMP := TIMESTAMP '2018-02-06 19:44:00';
   res INTEGER := 0;
BEGIN
    FOR i IN 1..30 LOOP
        DBMS_SCHEDULER.EVALUATE_CALENDAR_STRING('JOB_PERIOD_1,JOB_PERIOD_2', NULL, next_run_date, next_run_date);
        DBMS_OUTPUT.PUT_LINE(next_run_date);
    END LOOP;
END;