一、在PLSQL中创建表:
<!-- <br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->create table HWQY.TEST(CARNO VARCHAR2(30),CARINFOID NUMBER)
二、在PLSQL中创建存储过程:
<!-- <br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->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;
三、在SQL命令窗口中启动任务:
在SQL>后执行:
<!-- <br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->VARIABLE jobno number;
begin
DBMS_JOB.SUBMIT(:jobno,'pro_test;',SYSDATE,'sysdate+1/24/12');
commit;
end;
/
四、跟踪任务的情况(查看任务队列):
<!-- <br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->SQL> select job,next_date,next_sec,failures,broken from user_jobs;
六、查看进程数:
<!-- <br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->show parameter job_queue_processes;
--必须>0,否则执行下面的命令修改:
alter system set job_queue_processes=5;
七、再创建一个任务(每5分钟执行一次):
<!-- <br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->variable jobno number;
begin
dbms_job.submit(:jobno, 'pro_test;',sysdate,'sysdate+1/24/12');
commit;
end;
/