变量的声明,赋值,打印(declare是pl/sql里面的用法 variable是sql*plus里面的用法,variable相当于一个sql*plus环境的全局变量,declare里定义的是pl/sql中的局部变量)
declare job1 nvarchar2(10):='12154'; begin dbms_output.put_line(job1); end;
在pl/sql里面执行存储过程,不需要关键字exec,所有执行语句必须在begin....end里面,每条语句要有分号分隔。
create table a(a date); select * from a create or replace procedure job_test as begin insert into a (a)values(sysdate); commit; end; begin job_test; end;
创建作业要在sql/plus命令窗口执行,1/1440表示一分钟执行一次
SQL> variable job1 number; SQL> begin 2 dbms_job.submit(:job1,'job_test;',sysdate,'sysdate+1/1440'); 3 end; 4 / PL/SQL procedure successfully completed job1 --------- 43 SQL> begin 2 dbms_job.run(:job1); 3 end; 4 / PL/SQL procedure successfully completed job1 --------- 43 SQL> begin 2 dbms_job.remove(:job1); 3 end; 4 / PL/SQL procedure successfully completed job1 --------- 43
参考:
1.http://bbs.chinaunix.net/thread-251208-1-1.html
2.http://www.cnblogs.com/cycsa/archive/2013/06/04/3117786.html
vinson