Reputation: 75
I am trying to drop the queue using following command:
EXECUTE DBMS_AQADM.DROP_QUEUE (queue_name => 'ORDVAL_QUEUE');
It is working fine but i want to put a check if queue does not exist and i execute above command thn it should not throw an error or exception. I m using this but din't got my target :
BEGIN
EXECUTE IMMEDIATE 'DBMS_AQADM.DROP_QUEUE (queue_name => "ORDVAL_QUEUE")';
EXCEPTION
WHEN OTHERS THEN
null;
END;
It executes fine but does not drop queue.
Upvotes: 0
Views: 3643
Reputation: 36912
I haven't used queues before, but this should help:
BEGIN
and END
to the execute immediate, to use dynamic PL/SQL instead of dynamic SQL.OTHERS
. This was catching and ignoring unexpected exceptions.ALL_QUEUES
instead?DECLARE QUEUE_DOES_NOT_EXIST EXCEPTION; PRAGMA EXCEPTION_INIT(QUEUE_DOES_NOT_EXIST, -24010); BEGIN EXECUTE IMMEDIATE 'BEGIN DBMS_AQADM.DROP_QUEUE (queue_name => ''ORDVAL_QUEUE''); END;'; EXCEPTION WHEN queue_does_not_exist then dbms_output.put_line('Test to see if exception was thrown'); END; /
Upvotes: 1