?
?
drop sequence s_CarInfoID ; drop table test ; / --创建序列 create sequence s_CarInfoID --序列名 increment by 1 --每次增加1 start with 1 --从1开始 nomaxvalue --没有最大值 nocache --没有缓存序列 / --创建表 create table TEST ( CARNO VARCHAR2(30), CARINFOID NUMBER ) / create or replace procedure pro_test AS carinfo_id number; BEGIN select s_CarInfoID.nextval into carinfo_id from dual; insert into test(test.carno,test.carinfoid) values(carinfo_id,'123'); commit; end pro_test; / --检查是否存在 pro_test定时任务 ,有的话先删除 declare jobno number; countnum int; begin select count(1) into countnum from user_jobs WHERE what like '%pro_test%'; if (countnum = 1) then select job into jobno FROM user_jobs WHERE what like '%pro_test%'; DBMS_JOB.REMOVE(jobno); COMMIT; end if; end; / ---增加一个定时任务 VARIABLE jobno number; begin DBMS_JOB.SUBMIT(:jobno, 'pro_test;', SYSDATE,'sysdate+1/24/12'); --5分钟执行一次 commit; end; / --检查任务 select job,next_date,next_sec,failures,broken from user_jobs --执行任务 begin dbms_job.run(51); commit; end; --删除任务 begin dbms_job.remove(51); commit; end;
?