CREATE OR REPLACE PROCEDURE maXPro AS n integer; status NUMBER; BEGIN FOR N IN 1..30 LOOP DBMS_PIPE.PURGE('maxpro'); --清除原管道信息 DBMS_PIPE.PACK_MESSAGE(N); --把信息放入缓冲区 status:=DBMS_PIPE.SEND_MESSAGE('maxpro'); DBMS_LOCK.SLEEP(1); END LOOP; DBMS_PIPE.PURGE('maxpro'); --清除原管道信息 DBMS_PIPE.PACK_MESSAGE(999999); --把信息放入缓冲区,用999999 表示过程完成 status:=DBMS_PIPE.SEND_MESSAGE('maxpro'); END maxpro;
CREATE OR REPLACE PROCEDURE readmaxpro AS n integer; status integer; begin --接受等待时间为1秒,可以为0,立即调用或 DBMS_PIPE.RECEIVE_MESSAGE('mypipe') 等待100天 status:= DBMS_PIPE.RECEIVE_MESSAGE('maxpro',0); --status为0为成功可以UNPACK_MESSAGE,1为超时没有数据, 2为信息太大,3为内部错误 IF status <> 0 THEN DBMS_OUTPUT.PUT_LINE('管道中现在没有信息返回'); return; END IF; DBMS_PIPE.UNPACK_MESSAGE(n); DBMS_OUTPUT.PUT_LINE('maxpro 的当前进行状态为' n); end;
CREATE OR REPLACE PROCEDURE beginmaxpro AS JOB BINARY_INTEGER; BEGIN DBMS_JOB.SUBMIT(JOB,'maxpro;',sysdate,NULL,FALSE); DBMS_OUTPUT.PUT_LINE('队列号码JOB=' JOB); COMMIT; end;
CREATE OR REPLACE PROCEDURE readmaxpro(p out intergr) AS n integer; status integer; begin status:= DBMS_PIPE.RECEIVE_MESSAGE('maxpro',0); IF status <> 0 THEN P:=-1; return; END IF; DBMS_PIPE.UNPACK_MESSAGE(p); end;