From 0d63398f3bbdc110190ad65f7d4b48143bb5c884 Mon Sep 17 00:00:00 2001
From: Sebastien Ponce <sebastien.ponce@cern.ch>
Date: Mon, 1 Dec 2014 13:36:30 +0100
Subject: [PATCH] Fixed dropping of advanced queues in case they do not even
 exist

---
 castor/db/drop_oracle_schema.sql | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/castor/db/drop_oracle_schema.sql b/castor/db/drop_oracle_schema.sql
index 6a5a06ad07..446e0df47f 100644
--- a/castor/db/drop_oracle_schema.sql
+++ b/castor/db/drop_oracle_schema.sql
@@ -48,10 +48,17 @@ BEGIN
         DECLARE
           compilation_error exception;
           pragma exception_init(compilation_error, -6550);
+          invalid_statement EXCEPTION;
+          pragma exception_init(invalid_statement, -900);
         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
+        EXCEPTION
+        WHEN invalid_statement THEN
+          -- the statement IS valid, but this is raised when the queue does not exist
+          -- so we should just ignore it
+          NULL;
+        WHEN compilation_error THEN
           DECLARE
             error_code VARCHAR2(20) := regexp_substr(dbms_utility.format_error_stack, '(PLS-[[:digit:]]+):', 1, 1, '', 1);
           BEGIN
-- 
GitLab