码迷,mamicode.com
首页 > 数据库 > 详细

ORACLE JOB创建

时间:2017-02-19 20:20:53      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:end   submit   into   created   create   启动   database   comm   lis   

Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 
Connected as focususer

SQL> 
SQL> --JOB 需要在命令行执行;
SQL>  --抽数job
SQL>   CREATE OR REPLACE PROCEDURE RPT
  2  --业务
  3   AS
  4    v_time    VARCHAR2(20); /*运行当天*/
  5    v_timeold VARCHAR2(20); /*运行前一天*/
  6  
  7  BEGIN
  8    --查询系统时间
  9    select to_char(sysdate, yyyy-mm-dd), to_char(sysdate - 1, yyyy-mm-dd)
 10      into v_time, v_timeold
 11      from dual;
47         commit;
 48    --异常情况处理
 49  
 50  EXCEPTION
 51    WHEN OTHERS THEN
 52      ROLLBACK;
 53  END RPT;
 54  /

Procedure created
SQL> --新建JOB
SQL>   --SM_MANUAL_SM_LIST的job
SQL> variable   job2  number;
SQL> begin
  2    sys.dbms_job.submit(:job2,
  3                        RPT;,
  4                        to_date(22-03-2016 06:00:00,
  5                                dd-mm-yyyy hh24:mi:ss),
  6                        TRUNC(SYSDATE+1,‘‘DD‘‘)+360/1440);
  7    commit;
  8  end;
  9  /

PL/SQL procedure successfully completed
job2
---------
69
SQL> commit;

Commit complete
SQL> --启动JOB
SQL> begin
  2    sys.dbms_job.run(:job2);
  3    end;
  4  /

PL/SQL procedure successfully completed
job2
---------
69
SQL> --移除JOB
SQL> begin
  2    sys.dbms_job.remove(:job2);
  3    end;
  4  /

PL/SQL procedure successfully completed
job2
---------
69

 

ORACLE JOB创建

标签:end   submit   into   created   create   启动   database   comm   lis   

原文地址:http://www.cnblogs.com/dava/p/6416676.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!