The SEND_MESSAGE procedure sends a message from the session's local message buffer to a specified pipe.
>>-DBMS_PIPE.SEND_MESSAGE--(--pipename--+------------+--+----------------+--)->< '-,--timeout-' '-,--maxpipesize-'
Status code | Description |
---|---|
0 | Success |
1 | Time out |
EXECUTE privilege on the DBMS_PIPE module.
In proc1, send a message. In proc2, receive and unpack the message. Timeout if the message is not received within 1 second.
SET SERVEROUTPUT ON@
CREATE PROCEDURE proc1()
BEGIN
DECLARE status INTEGER;
SET status = DBMS_PIPE.CREATE_PIPE( 'pipe1' );
SET status = DBMS_PIPE.PACK_MESSAGE('message1');
SET status = DBMS_PIPE.SEND_MESSAGE( 'pipe1' );
END@
CREATE PROCEDURE proc2()
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);
CALL DBMS_PIPE.UNPACK_MESSAGE(v_item);
CALL DBMS_OUTPUT.PUT_LINE('Item: ' || v_item);
END@
CALL proc1@
CALL proc2@
This example results in the following output:
RECEIVE_MESSAGE status: 0
Item: message1