-- pipe_receive.sql

SET SERVEROUTPUT ON
DECLARE
  message VARCHAR2(256);
BEGIN
-- The first message has 3 items within a single message.
  IF DBMS_PIPE.RECEIVE_MESSAGE('LabPipe', 120) = 0 THEN
    DBMS_PIPE.UNPACK_MESSAGE(message);
    DBMS_OUTPUT.PUT_LINE(message);
    DBMS_PIPE.UNPACK_MESSAGE(message);
    DBMS_OUTPUT.PUT_LINE(message);
    DBMS_PIPE.UNPACK_MESSAGE(message);
    DBMS_OUTPUT.PUT_LINE(message);
  ELSE
    DBMS_OUTPUT.PUT_LINE('Message failed or timed out');
  END IF;

-- The second part is three messages, each with a single item.
  IF DBMS_PIPE.RECEIVE_MESSAGE('LabPipe', 120) = 0 THEN
    DBMS_PIPE.UNPACK_MESSAGE(message);
    DBMS_OUTPUT.PUT_LINE(message);
  ELSE
    DBMS_OUTPUT.PUT_LINE('Message failed or timed out');
  END IF;
  IF DBMS_PIPE.RECEIVE_MESSAGE('LabPipe', 120) = 0 THEN
    DBMS_PIPE.UNPACK_MESSAGE(message);
    DBMS_OUTPUT.PUT_LINE(message);
  ELSE
    DBMS_OUTPUT.PUT_LINE('Message failed or timed out');
  END IF;
  IF DBMS_PIPE.RECEIVE_MESSAGE('LabPipe', 120) = 0 THEN
    DBMS_PIPE.UNPACK_MESSAGE(message);
    DBMS_OUTPUT.PUT_LINE(message);
  ELSE
    DBMS_OUTPUT.PUT_LINE('Message failed or timed out');
  END IF;
END;
/
