What this does (interpreting the two-argument form of RECEIVE_MESSAGE):
- CHR(99) is the ASCII for 'c'. CHR(99)||CHR(99)||CHR(99) evaluates to 'ccc'.
- DBMS_PIPE.RECEIVE_MESSAGE('ccc', 0) tries to read a message from the pipe named CCC (pipe names are treated in uppercase by Oracle) with a timeout of 0 seconds.
- The second argument 0 means a non-blocking read: if there is a message already queued in the pipe, it returns that message; if not, it returns NULL (no waiting).
Notes:
- The function returns the message content as a VARCHAR2. You should assign it to a variable to use it.
- The pipe must exist and you must have the necessary privileges to read from it.
- If you want to wait for a message, pass a positive timeout (e.g., 5 for 5 seconds).
Example:
DECLARE l_msg VARCHAR2(32767); BEGIN l_msg := DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99), 0); IF l_msg IS NULL THEN DBMS_OUTPUT.PUT_LINE('No message available.'); ELSE DBMS_OUTPUT.PUT_LINE('Received: ' || l_msg); END IF; END;
If you want a blocking read, use a positive timeout, e.g., 5 or 30 seconds.
