Friday, May 4, 2012

Purge Queue Table


BEGIN
FOR cur_rec IN (SELECT owner,queue_table FROM dba_queue_tables where owner not in ('DBSNMP','ORACLE_OCM','OUTLN','SYS','SYSMAN','SYSTEM','TSMSYS','WMSYS','XDB')) LOOP
DECLARE
 po_t dbms_aqadm.aq$_purge_options_t;
    BEGIN
DBMS_AQADM.PURGE_QUEUE_TABLE('' || cur_rec.owner || '' || '.' || '' || cur_rec.queue_table || '', NULL, po_t);
    END;
  END LOOP;
END;
/


----------------Schema Tables---------

BEGIN
FOR cur_rec IN (SELECT queue_table FROM user_queue_tables) LOOP
DECLARE
 po_t dbms_aqadm.aq$_purge_options_t;
    BEGIN
DBMS_AQADM.PURGE_QUEUE_TABLE('' || cur_rec.queue_table || '', NULL, po_t);
    END;
  END LOOP;
END;
/

------------Purge Specific Table

BEGIN
FOR cur_rec IN (SELECT queue_table FROM user_queue_tables) LOOP
DECLARE
 po_t dbms_aqadm.aq$_purge_options_t;
    BEGIN
      DBMS_AQADM.PURGE_QUEUE_TABLE('TBLRKQUEUE', NULL, po_t);
    EXCEPTION
      WHEN OTHERS THEN
        NULL;
    END;
  END LOOP;
END;
/

No comments:

Post a Comment

Followers