RK Cruz
RK Cruz

Reputation: 21

Oracle DB Job Scheduler

I would like to create a scheduled job that will every 1st day of the month.

Below is the job that I manually run every 1st day of the month:

his_proc_mduniverse.md_proc_universe(v_date1, v_date2)

Example:

his_proc_mduniverse.md_proc_universe('01-JAN-2014' , '31-JAN-2014')

Given that I need to populate the starting and end dates every month, how can I implement this via job schedule?

Upvotes: 2

Views: 1750

Answers (1)

Rimas
Rimas

Reputation: 6024

You can create Job for this task:

BEGIN
DBMS_SCHEDULER.CREATE_JOB (
   job_name        => 'my_new_job1',
   job_type        => 'plsql_block',
   job_action      => 'BEGIN his_proc_mduniverse.md_proc_universe(TRUNC(SYSDATE, ''month''), TRUNC(LAST_DAY(SYSDATE))); END;',
   repeat_interval => 'FREQ=MONTHLY;BYMONTHDAY=1',
   enabled         => TRUE,
   auto_drop       => FALSE,
   comments        => 'every 1st day of the month');
END;
/

EDIT: To run at specified time (eg. 5 am) change repeat_interval to:

repeat_interval => 'FREQ=MONTHLY;BYMONTHDAY=1;BYHOUR=5;BYMINUTE=0;BYSECOND=0',

Documentation:

Upvotes: 1

Related Questions