--
select count(*) 
  from XDBMETADATA.REPOSITORY_EVENTS_TABLE
/
declare 
  pending     number(32);  
  i           number(32);
  deq_ct      dbms_aq.dequeue_options_t;
  msg_prop    dbms_aq.message_properties_t;
  enq_msgid   raw(16);
   xmlPayload XMLType;
begin
   select count(*)
     into PENDING
     from XDBMETADATA.REPOSITORY_EVENTS_TABLE;
     
   for i in 1..PENDING loop
     DBMS_AQ.DEQUEUE(XDB_ASYNCHRONOUS_EVENTS.REPOSITORY_EVENTS_QUEUE, deq_ct, msg_prop, xmlPayload, enq_msgid);
     IMAGE_PROCESSOR.HANDLE_EVENT(xmlPayload);
   end loop;
end;
/
select count(*) 
  from XDBMETADATA.REPOSITORY_EVENTS_TABLE
/
--