Creating a Job in Oracle using DBMS_JOB

不羁的心 提交于 2019-12-05 05:02:22

问题


I'm trying to create a job that will run a certain procedure every Christmas. This is how far I have gotten:

declare
   jobno number;
begin
   dbms_job.submit( jobno,
                   'BEGIN GiveCoins; END;',
                    to_date('12/25', 'MM/DD'),
                    'sysdate + ?');
end;
/

However I can't seem to find an easy way to change the interval to yearly and am just generally quite confused about how to go about this, any help greatly appreciated


回答1:


You'd want something like

declare
   jobno number;
begin
   dbms_job.submit( jobno,
                   'BEGIN GiveCoins; END;',
                    to_date('12/25/2012', 'MM/DD/YYYY'),
                    'add_months(trunc(sysdate),12)');
end;
/

This will run the job for the first time at midnight on Christmas 2012 and every 12 months after that.



来源:https://stackoverflow.com/questions/10538406/creating-a-job-in-oracle-using-dbms-job

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!