diff --git a/castor/db/drop_oracle_schema.sql b/castor/db/drop_oracle_schema.sql index 7b781eb09121a8f6a71c3f0fa182b0581fafa7c9..6a5a06ad078188552e8623405fbf15df38c6bf82 100644 --- a/castor/db/drop_oracle_schema.sql +++ b/castor/db/drop_oracle_schema.sql @@ -45,8 +45,23 @@ BEGIN ELSIF rec.object_type = 'SYNONYM' THEN EXECUTE IMMEDIATE 'DROP SYNONYM '||rec.object_name; ELSIF rec.object_type = 'QUEUE' THEN - DBMS_AQADM.STOP_QUEUE(queue_name => rec.object_name); - DBMS_AQADM.DROP_QUEUE(queue_name => rec.object_name); + DECLARE + compilation_error exception; + pragma exception_init(compilation_error, -6550); + BEGIN + execute immediate 'DBMS_AQADM.STOP_QUEUE(queue_name => rec.object_name);'; + execute immediate 'DBMS_AQADM.DROP_QUEUE(queue_name => rec.object_name);'; + EXCEPTION WHEN compilation_error THEN + DECLARE + error_code VARCHAR2(20) := regexp_substr(dbms_utility.format_error_stack, '(PLS-[[:digit:]]+):', 1, 1, '', 1); + BEGIN + -- Ignore PLS-00201: identifier 'DBMS_AQADM' must be declared + -- as obviously, there is nothing to be dropped + IF error_code != 'PLS-00201' THEN + RAISE; + END IF; + END; + END; END IF; EXCEPTION WHEN OTHERS THEN -- Ignore: ORA-04043: "object string does not exist" or