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

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

Upvotes: 2

Views: 19960

Answers (1)

Muff
Muff

Reputation: 75

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;
/

Upvotes: 5

Related Questions