The REMOVE_PIPE function deletes an explicitly created pipe. Use this function to delete any public or private pipe that was created by the CREATE_PIPE function.
This function returns one of the following status codes of type INTEGER.
Status code | Description |
---|---|
0 | Pipe successfully removed or does not exist |
NULL | An exception is thrown |
EXECUTE privilege on the DBMS_PIPE module.
In proc1 send two messages on a pipe: Message #1 and Message #2. In proc2, receive the first message, unpack it, and then delete the pipe. When proc3 runs, the call to the RECEIVE_MESSAGE function times out and returns the status code 1 because the pipe no longer exists.
SET SERVEROUTPUT ON@
CREATE PROCEDURE proc1()
BEGIN
DECLARE v_status INTEGER;
DECLARE status INTEGER;
SET v_status = DBMS_PIPE.CREATE_PIPE('pipe1');
CALL DBMS_OUTPUT.PUT_LINE('CREATE_PIPE status : ' || v_status);
SET status = DBMS_PIPE.PACK_MESSAGE('Message #1');
SET v_status = DBMS_PIPE.SEND_MESSAGE('pipe1');
CALL DBMS_OUTPUT.PUT_LINE('SEND_MESSAGE status: ' || v_status);
SET status = DBMS_PIPE.PACK_MESSAGE('Message #2');
SET v_status = DBMS_PIPE.SEND_MESSAGE('pipe1');
CALL DBMS_OUTPUT.PUT_LINE('SEND_MESSAGE status: ' || v_status);
END@
CREATE PROCEDURE proc2()
BEGIN
DECLARE v_item VARCHAR(80);
DECLARE v_status INTEGER;
DECLARE status INTEGER;
SET v_status = DBMS_PIPE.RECEIVE_MESSAGE('pipe1',1);
CALL DBMS_OUTPUT.PUT_LINE('RECEIVE_MESSAGE status: ' || v_status);
CALL DBMS_PIPE.UNPACK_MESSAGE(v_item);
CALL DBMS_OUTPUT.PUT_LINE('Item: ' || v_item);
SET status = DBMS_PIPE.REMOVE_PIPE('pipe1');
END@
CREATE PROCEDURE proc3()
BEGIN
DECLARE v_item VARCHAR(80);
DECLARE v_status INTEGER;
SET v_status = DBMS_PIPE.RECEIVE_MESSAGE('pipe1',1);
CALL DBMS_OUTPUT.PUT_LINE('RECEIVE_MESSAGE status: ' || v_status);
END@
CALL proc1@
CALL proc2@
CALL proc3@
This example results in the following output.
From proc1:
CREATE_PIPE status : 0
SEND_MESSAGE status: 0
SEND_MESSAGE status: 0
From proc2:
RECEIVE_MESSAGE status: 0
Item: Message #1
From proc3:RECEIVE_MESSAGE status: 1