Question

I have job, created using DBMS_JOB, which runs daily at 1:00 am

    WHAT        PROC_XYZ();
    NEXT_DATE   16-OCT-13
    NEXT_SEC    01:00:00
    INTERVAL    trunc(sysdate)+1+1/24

I want to change it to run at specific dates (with no pattern or fixed interval), for instance: 30 Oct 2013, 14 Nov 2013, 18 Nov 2013

Is there a way I can specify a list of dates for the job to run?

Was it helpful?

Solution

No.

BUT, you can create a list of the dates that you want the job to run and check whether the current date is one of those dates before executing the procedure. The RETURN statement will return control to the invoking code as soon as it's executed in a procedure.

So, add something like this to the first executed line of your procedure:

if trunc(sysdate) not in (date '2013-10-30', date '2013-11-14') then
   return;
end if;

I would probably use a table rather than a list of dates so it's easy to modify without changing code. If you run the job every day then it will exit immediately all days but those you want to it to run completely.

It's worth reading the note at the top of the DBMS_JOB docs:

The DBMS_JOB package has been superseded by the DBMS_SCHEDULER package. In particular, if you are administering jobs to manage system load, you should consider disabling DBMS_JOB by revoking the package execution privilege for users.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top