set serveroutput on DECLARE xmldoc xmldom.DOMDocument; ordId NUMBER; c NUMBER := 0; BEGIN dbms_output.put_line('XML Dequeue Test in Session '|| userenv('SESSIONID')); WHILE (TRUE) LOOP -- Dequeue XML message from the 'xml_msg_queue' queue (Don't Wait) xmldoc := xmlq.dequeue('xml_msg_queue', wait=>false); -- Use xpath.valueOf to look in XML message content to find ordId ordId := xpath.valueOf(xmldoc,'/order/@id'); -- Processing the current message (Here just print a message!) dbms_output.put_line('Processing Order #'||ordId); -- Free the current XML document xml.freeDocument(xmldoc); END LOOP; EXCEPTION WHEN xmlq.queue_empty THEN dbms_output.put_line('No more orders to process.'); END; |