I have created an oracle jobs that triggered my stored procedure to run everyday at 5 AM.But i want to restrict the job to run only from Monday to Friday at 5 AM.Here is the job that i have written:
DECLARE
X NUMBER;
BEGIN
SYS.DBMS_JOB.SUBMIT (
job => X ,
what => 'BEGIN usp_procedurename(''ENV''); END;' ,
next_date => to_date('10/01/2014 05:00:00','dd/mm/yyyy hh24:mi:ss') ,
interval => 'SYSDATE + 1' ,
no_parse => FALSE );
SYS.DBMS_OUTPUT.PUT_LINE('Job Number is: ' || to_char(x));
COMMIT;
END;
Is there is some way that i can change the interval that will restrict the job to run only from Monday to Friday at 5 AM or is there any other way ?
Any help on this is appreciated. Thanks
Don't use dbms_job - it has long since been deprecated and superseded by dbms_scheduler.
With dbms_scheduler, this should do what you want:
Note: You should always use a timestamp with timezone for the start date; otherwise, your job will run at different times when your country switches from/to daylight saving time.