我想用这些属性创建oracle dbms scheduler作业:
FREQ=MINUTELY INTERVAL=10 BYDAY=MON TUE WED THU FRI
BYHOUR=7,8,9,10,11,12,13,14,15,16,17,18
但是,除此之外,我希望在下午14点到16点期间,同样的工作每5分钟一次,晚上14点之前和下午16点之后工作10分钟。
答案 0 :(得分:2)
最好的方法是创建时间表:
BEGIN
DBMS_SCHEDULER.CREATE_SCHEDULE (
schedule_name => 'my_first_schedule',
start_date => SYSTIMESTAMP,
repeat_interval => 'FREQ=MINUTELY;INTERVAL=5;BYHOUR=14,15,16;BYDAY=MON,TUE,WED,THU,FRI',
comments => 'Every 10 minutes from 2pm to 4pm');
END;
/
BEGIN
DBMS_SCHEDULER.CREATE_SCHEDULE (
schedule_name => 'my_second_schedule',
start_date => SYSTIMESTAMP,
repeat_interval => 'FREQ=MINUTELY;INTERVAL=10;BYHOUR=7,8,9,10,11,12,13,17,18;BYDAY=MON,TUE,WED,THU,FRI',
comments => 'Every 5 minutes from 7am to 2pm and from 5pm to 6pm');
END;
/
BEGIN
DBMS_SCHEDULER.CREATE_JOB(
JOB_NAME => 'JOB',
JOB_TYPE => 'STORED_PROCEDURE',
JOB_ACTION => 'SCHED_TEST_JOB_PROCEDURE',
START_DATE => SYSTIMESTAMP,
REPEAT_INTERVAL => 'FREQ=my_first_schedule,my_second_schedule;',
AUTO_DROP => FALSE,
ENABLED => TRUE);
END;
/