DECLARE
  qname              VARCHAR2(100);
  enqueue_options    dbms_aq.enqueue_options_t;
  message_properties dbms_aq.message_properties_t;
  msgid              RAW(16);
  contract_msg       VARCHAR2(1000);
  payload            AQ_SERVICE_EXCEPTION_T;

BEGIN
  qname := 'SERVICE_EXCEPTIONS_Q';

  for exception_cur in (select CORRELATION_ID,
                               process_name,
                               INSTANCE_ID,
                               sysdate as "ERROR_TIMESTAMP",
                               eRROR_CATEGORY,
                               ERROR_MESSAGE,
                               INPUT_MESSAGE,
                               from service_exceptions se 
                          --where se.INSTANCE_ID in ('3403804', '3413801')
                         ) loop
    payload := AQ_SERVICE_EXCEPTION_T(exception_cur.CORRELATION_ID, exception_cur.process_name, exception_cur.INSTANCE_ID, exception_cur.CALLING_SERVICE, exception_cur.CALLED_SERVICE, exception_cur.ERROR_TIMESTAMP, exception_cur.ERROR_CATEGORY, exception_cur.ERROR_MESSAGE, exception_cur.INPUT_MESSAGE, 
    exception_cur.STATUS_CODE, exception_cur.ACTION_PERFORMED_BY, exception_cur.ACTIONED_TIMESTAMP);
  
    dbms_aq.enqueue(queue_name         => qname,
                    enqueue_options    => enqueue_options,
                    message_properties => message_properties,
                    payload            => payload,
                    msgid              => msgid);
  end loop;

  commit;
END;
