To schedule a job, first we have to create a schedule, then a program, and then a job.
- We create a schedule using the following SQL command:
BEGIN DBMS_SCHEDULER.CREATE_SCHEDULE ( Schedule_name => 'DAILYREPORTJOB', Start_date => SYSTIMESTAMP, Repeat_interval =>'FREQ=DAILY;BYHOUR=11; BYMINUTE=30', Comments => 'DAILY REPORT JOB' ); END;
- And then we create a program using the following SQL command:
BEGIN DBMS_SCHEDULER.CREATE_PROGRAM ( program_name => 'DAILYREPORTJOB', program_type => 'STORED_PROCEDURE', program_action => 'DAILYJOB.REPORTPROC' number_of_arguments =>0, enabled => TRUE, comments => 'DAILY REPORT JOB' ); END;
- And now create the job :
BEGIN DBMS_SCHEDULER.CREATE_JOB ( job_name => 'DAILYREPORTJOB_RUN', program_name => 'DAILYREPORTJOB', schedule_name => 'DAILYREPORTJOB_SCHED', enabled => FLASE, comments => 'daily REPORT job' ); END;
- Finally enable the job:
EXECUTE DBMS_SCHEDULER.ENABLE('DAILYREPORTJOB_RUN');
Amen Answered question 11/04/2023