How to schedule a job to run twice a day using dbms_scheduler

社会主义新天地 提交于 2019-12-24 08:18:05

问题


I have created a job using DBMS_SCHEDULER, which will call a SP and the SP does the required stuff. Now my question is how to schedule that job to run twice a day ? I mean I want that job to run everyday @ 1 PM and 4PM (this is just an example. I may have to run @ diff time, but will be running daily twice).

Thanks

Sachi


回答1:


it's easy.

Using PL/SQL Developer, open Jobs and edit certain job. In Job properties in Schedule section set "Frequency" to Daily and "By hour" parameter to "1,4".

Using PL/SQL code it will be like this:

BEGIN
 DBMS_SCHEDULER.CREATE_JOB (
   job_name        => 'sachi.example_job',
   job_type        => 'PLSQL_BLOCK',
   job_action      => 'BEGIN      
                         DBMS_STATS.GATHER_TABLE_STATS(''sachi'',''anytablename'');  
                       END;',
   start_date      =>  TO_DATE('22-02-2013 14:00','DD-MM-YYYY HH24:MI'),
   repeat_interval => 'FREQ=DAILY; BYHOUR=11,15', 
   enabled         =>  TRUE,
   comments        => 'Gather table statistics');
END;
/


来源:https://stackoverflow.com/questions/13859115/how-to-schedule-a-job-to-run-twice-a-day-using-dbms-scheduler

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!