What you posted isn’t valid PL/SQL as-is.
- CHR(99)||CHR(99)||CHR(99) evaluates to the string 'ccc', but you cannot pass a literal (or an expression) to an OUT parameter like RECEIVE_MESSAGE. The first parameter must be a variable that the procedure will fill.
- The 0 timeout means non-blocking: if a message is available in the pipe, it will be written to the buffer; if not, the buffer will typically be NULL after the call.
Correct usage (example):
- Declare a buffer, then receive into it:
DECLARE v_msg VARCHAR2(32767); BEGIN DBMS_PIPE.RECEIVE_MESSAGE(v_msg, 0); -- non-blocking IF v_msg IS NOT NULL THEN DBMS_OUTPUT.PUT_LINE('Received: ' || v_msg); ELSE DBMS_OUTPUT.PUT_LINE('No message available'); END IF; END; /
- If you want to wait for a message, specify a positive timeout (in seconds):
DECLARE v_msg VARCHAR2(32767); BEGIN DBMS_PIPE.RECEIVE_MESSAGE(v_msg, 5); -- wait up to 5 seconds IF v_msg IS NOT NULL THEN DBMS_OUTPUT.PUT_LINE('Received: ' || v_msg); ELSE DBMS_OUTPUT.PUT_LINE('No message after timeout'); END IF; END; /
Notes:
- Ensure the pipe is created and that another session has sent a message to it (using DBMS_PIPE.SEND_MESSAGE) before calling RECEIVE_MESSAGE.
- The maximum size of v_msg depends on your Oracle version; VARCHAR2(32767) is a safe upper bound in PL/SQL.
