DECLARE /* Holds the status ofthe pipe actions */ pipe_status INTEGER; /* Control WHILE loop to continue unpacking items from message */ get_next_item BOOLEAN; /* Declare PL/SQL table structure and table itself. */ TYPE item_tabtype IS TABLE OF NUMBER INDEX BY BINARY_INTEGER; item_table item_tabtype; /* Individual item variable */ item_value NUMBER; /* Count of rows in table */ item_row INTEGER := 0; /* Exception to handle the empty pipe. */ empty_pipe EXCEPTION; PRAGMA EXCEPTION_INIT (empty_pipe, -6556); /* Exception to handle the wrong type phenomena. */ wrong_item_type EXCEPTION; PRAGMA EXCEPTION_INIT (wrong_item_type, -6559); BEGIN /* Move the message from the pipe to the buffer. Wait a minute. */ pipe_status := DBMS_PIPE.RECEIVE_MESSAGE ('many_items', 60); /* Set up loop condition: do nothing if no message. */ get_next_item := pipe_status = 0; WHILE get_next_item LOOP /* New block for UNPACK_MESSAGE */ BEGIN /* Try to unpack the next item */ DBMS_PIPE.UNPACK_MESSAGE (item_value); /* || If I got here there was another item, so increment the || row number and place the value in the table. */ item_row := item_row + 1; item_table (item_row) := item_value; EXCEPTION /* Table is empty so turn off the loop */ WHEN empty_pipe THEN get_next_item := FALSE; END; END LOOP; EXCEPTION WHEN wrong_item_type THEN RAISE_APPLICATION_ERROR (-20556, 'Bad item type in the many_items pipe!'); END;