SEND_MESSAGE procedure - Send a message to a specified pipe
The SEND_MESSAGE procedure sends a message from the session's local message buffer to a specified pipe.
Syntax
Return value
This procedure returns one
of the following status codes of type INTEGER.
| Status code | Description |
|---|---|
| 0 | Success |
| 1 | Time out |
Procedure parameters
- pipename
- An input argument of type VARCHAR(128) that specifies the name of the pipe. If the specified pipe does not exist, the pipe is created implicitly. For more information about pipes, see DBMS_PIPE module.
- timeout
- An optional input argument of type INTEGER that specifies the wait time in seconds. The default is 86400000 (1000 days).
- maxpipesize
- An optional input argument of type INTEGER that specifies the maximum capacity of the pipe in bytes. The default is 8192 bytes.
Authorization
EXECUTE privilege on the DBMS_PIPE module.
Examples
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