oracle jobs 定时任务

在plsql里添加job:

创建sql:
--------------------
DECLARE
jobid NUMBER;
begin
  sys.dbms_job.submit(job => jobid,
                      what => 'update ai_complain_common t set t.apply_close_date = to_date(to_char(apply_close_date,''yyyymmdd'')||''235959'',''yyyymmddhh24miss'')
where t.apply_close_date is not null and to_char(t.apply_close_date,''yyyymmdd'')= to_char(sysdate+1,''yyyymmdd'');update ai_complain_common_apply t set t.apply_close_date = to_date(to_char(apply_close_date,''yyyymmdd'')||''235959'',''yyyymmddhh24miss'')
where t.apply_close_date is not null and to_char(t.apply_close_date,''yyyymmdd'')= to_char(sysdate+1,''yyyymmdd'');',
                      next_date => to_date('25-10-2013 20:00:00', 'dd-mm-yyyy hh24:mi:ss'),
                      interval => 'trunc(sysdate)+21/24');
  commit;
end;
/

-------------
jobid : 系统会自动生成一个数字编号。
what :要执行的sql,注意单引号的处理。
next_date:下次执行时间,据说可以留空。
interval :周期,21/24=小时表述,1110/1440=分钟表述,可以用select trunc(sysdate)+21/24 from dual查看。
--------------
plsql界面操作如下:
----------

猜你喜欢

转载自sunnyhl.iteye.com/blog/1964767