Oracle定時任務

Orient_發表於2020-10-21
declare
  job_num number;
  iCount  number;
BEGIN
  select count(1)
    into iCount
    from user_jobs
   where what = '儲存過程;';
  if iCount != 0 then
    select job
      into job_num
      from user_jobs
     where what = '儲存過程;';
    DBMS_JOB.remove(job_num);
  end if;
  DBMS_JOB.SUBMIT(JOB       => job_num,
                  WHAT      => '儲存過程;',
                  NEXT_DATE => sysdate + 1,
                  INTERVAL  => 'TRUNC(sysdate+1)+3/24');
  commit;
end;
/

每天凌晨3點執行

相關文章