MINI MINI MANI MO

Path : /proc/self/root/opt/oracle/product/18c/dbhomeXE/md/admin/
File Upload :
Current File : //proc/self/root/opt/oracle/product/18c/dbhomeXE/md/admin/sdomigrt.sql

Rem Copyright (c) 2006, 2017, Oracle and/or its affiliates. 
Rem All rights reserved.
Rem
Rem    NAME
Rem      sdomigrt.sql - <one-line expansion of the name>
Rem
Rem    DESCRIPTION
Rem      <short description of component this file declares/defines>
Rem
Rem    NOTES
Rem      <other useful comments, qualifications, etc.>
Rem
Rem    BEGIN SQL_FILE_METADATA
Rem    SQL_SOURCE_FILE: sdo/admin/sdomigrt.sql
Rem    SQL_SHIPPED_FILE: md/admin/sdomigrt.sql
Rem    SQL_PHASE: UPGRADE
Rem    SQL_STARTUP_MODE: NORMAL
Rem    SQL_IGNORABLE_ERRORS: NONE
Rem    SQL_CALLING_FILE: sdo/admin/sdoupgrdh.sql
Rem    END SQL_FILE_METADATA
Rem
Rem    MODIFIED   (MM/DD/YY)
Rem    sravada     11/01/17 - revert MDSYS prefix change
Rem    rjanders    10/08/17 - Add MDSYS to spatial type
Rem    rjanders    06/30/17 - Add SYS/MDSYS prefixes
Rem    sravada     06/30/17 - lrg 20416681
Rem    sravada     06/05/17 - add more NULL exceptions for upgrade
Rem    sravada     05/31/17 - drop stats from spatial_index_v2
Rem    rjanders    05/10/17 - #26037683: Raise 'when other' exceptions
Rem    rjanders    04/27/17 - Correct "SQL_PHASE" metadata values
Rem    rjanders    03/26/17 - migration fixes
Rem    rjanders    03/23/17 - #25437999: Remove 'when others then NULL'
Rem                           handlers
Rem    sravada     03/20/17 - spatial_dummy_function_v2 fixes
Rem    rjanders    03/09/17 - Add missing SQL_FILE_METADATA information
Rem    sravada     01/11/17 - bug 25370681
Rem    sravada     02/21/16 - fix EOF
Rem    lramosc     02/12/16 - Reduce datasources
Rem    sravada     02/09/16 - add drop grants
Rem    rjanders    01/26/16 - #22564200: Remove tracefile warnings
Rem    rjanders    12/31/15 - #21925692: Add SDO_TABLE_NAME to index metadata
Rem    sravada     11/18/15 - remove dba_errors check
Rem    rjanders    09/16/15 - #21825604: Remove WITH GRANT OPTION from PUBLIC
Rem    sravada     04/08/15 - remove SDO_GET_ITYP_NAME
Rem    sravada     10/30/14 - bug 19649810
Rem    sravada     07/16/14 - lrg 12102029
Rem    rjanders    03/15/13 - #16473696: Start/End _ORACLE_SCRIPT
Rem                           initialization
Rem    sravada     09/17/12 - compile SDO_CACHED_MAP_DROP_USER
Rem    matperry    07/10/12 - do not drop rdf_match
Rem    sravada     06/13/12 - drop MDSYS.TokenSessionMap_t
Rem    sravada     05/03/12 - drop rtree_index
Rem    sravada     09/14/11 - add sdo_statistics type upg
Rem    rjanders    09/01/10 - Revoke execute on MDSYS.ORDMD_GMD_LIBS
Rem    yhu         01/27/10 - set 3D SDO_ROOT_MBR : gtype=3008, etype=1007
Rem    sravada     03/19/09 - alter the SDO_TOPO_OBJECT_ARRAY
Rem    sravada     12/02/08 - drop SDO_CACHED_MAP_DROP_USER
Rem    sravada     10/20/08 - lrg 3649854
Rem    sravada     09/15/08 - drop 10.2 not used objects
Rem    yhu         09/02/08 - bug 7372230: drop SDO_CMT_CBK_TRIG AND OTHER
Rem                           OBJECTS
Rem    sravada     05/14/08 - move sdomsttp.sql down
Rem    sravada     11/08/07 - revoke privs on LIBRARIES
Rem    sravada     04/09/07 - remove sdo_text_type
Rem    sravada     03/06/07 - bug 5916428
Rem    sravada     11/01/06 - bug 5590091
Rem    sravada     08/16/06 - lrg 2493460
Rem    mannamal    07/20/06 - fix lrg 2247076 (rdf upgrade)
Rem    sdas        06/14/06 - RDF upgrade to 11
Rem    ningan      04/11/06 - drop NDM related classes files
Rem    sravada     03/03/06 - Created
Rem


Rem ********************************************************************
Rem #16473696: Indicate Oracle-Supplied object
@@?/rdbms/admin/sqlsessstart.sql
Rem ********************************************************************

alter session set current_schema=MDSYS;

prompt starting sdotpwgo.sql
@@sdotpwgo.sql
prompt sdotpwgo.sql complete


create or replace type sdoridlist as varray(1048576) of varchar2(24)
/
show errors;

GRANT EXECUTE ON MDSYS.sdoridlist to PUBLIC;

create or replace type sdoridtab as table of varchar2(24)
/
show errors;

GRANT EXECUTE ON MDSYS.sdoridtab to PUBLIC;



prompt declare#1
declare
  already_revoked exception;
  pragma exception_init(already_revoked, -01927);
  package_not_found exception;
  pragma exception_init(package_not_found, -04042);
  object_invalid_in_pdb exception;
  pragma exception_init(object_invalid_in_pdb, -65047);
begin
  begin
    execute immediate 'revoke execute on ORDMD_SAM_LIBS from public';
    exception
      when package_not_found then NULL;
      when already_revoked then NULL;
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')1]: ' || SQLERRM); RAISE;
  end;

  begin
    execute immediate 'revoke execute on SDO_GEOR_LIZARDTECH_LIB from public';
    exception
      when package_not_found then NULL;
      when object_invalid_in_pdb then NULL;
      when others then
    SYS. DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                            'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')2]: ' || SQLERRM); RAISE;
  end;

  begin
    execute immediate 'revoke execute on ORDMD_GEOR_LIBS from public';
    exception
      when package_not_found then NULL;
      when already_revoked then NULL;
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')3]: ' || SQLERRM); RAISE;
  end;

  begin
    execute immediate 'revoke execute on ORDMD_GEORX_LIBS from public';
    exception
      when package_not_found then NULL;
      when already_revoked then NULL;
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')4]: ' || SQLERRM); RAISE;
  end;

  begin
    execute immediate 'revoke execute on ORDMD_TP_LIBS from public';
    exception
      when package_not_found then NULL;
      when already_revoked then NULL;
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')5]: ' || SQLERRM); RAISE;
  end;

  begin
    execute immediate 'revoke execute on ORDMD_AG_LIBS from public';
    exception
      when package_not_found then NULL;
      when already_revoked then NULL;
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')6]: ' || SQLERRM); RAISE;
  end;

  begin
    execute immediate 'revoke execute on ORDMD_LRS_LIBS from public';
    exception
      when package_not_found then NULL;
      when already_revoked then NULL;
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')7]: ' || SQLERRM); RAISE;
  end;

  begin
    execute immediate 'revoke execute on ORDMD_PRIDX_LIBS from public';
    exception
      when package_not_found then NULL;
      when already_revoked then NULL;
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')8]: ' || SQLERRM); RAISE;
  end;

  begin
    execute immediate 'revoke execute on ORDMD_UTL_LIBS from public';
    exception
      when package_not_found then NULL;
      when already_revoked then NULL;
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')9]: ' || SQLERRM); RAISE;
  end;

  begin
    execute immediate 'revoke execute on ORDMD_RTREE_LIBS from public';
    exception
      when package_not_found then NULL;
      when already_revoked then NULL;
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')10]: ' || SQLERRM); RAISE;
  end;

  begin
    execute immediate 'revoke execute on ORDMD_CS_LIBS from public';
    exception
      when package_not_found then NULL;
      when already_revoked then NULL;
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')11]: ' || SQLERRM); RAISE;
  end;

  begin
    execute immediate 'revoke execute on ORDMD_MIG_LIBS from public';
    exception
      when package_not_found then NULL;
      when already_revoked then NULL;
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')12]: ' || SQLERRM); RAISE;
  end;

  begin
    execute immediate 'revoke execute on ORDMD_UDT_LIBS from public';
    exception
      when package_not_found then NULL;
      when already_revoked then NULL;
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')13]: ' || SQLERRM); RAISE;
  end;

  begin
    execute immediate 'revoke execute on ORDMD_MBR_LIBS from public';
    exception
      when package_not_found then NULL;
      when already_revoked then NULL;
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')14]: ' || SQLERRM); RAISE;
  end;

  begin
    execute immediate 'revoke execute on ORDMD_WD_LIBS from public';
    exception
      when package_not_found then NULL;
      when already_revoked then NULL;
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')15]: ' || SQLERRM); RAISE;
  end;

  begin
    execute immediate 'revoke execute on ORDMD_REL_LIBS from public';
    exception
      when package_not_found then NULL;
      when already_revoked then NULL;
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')16]: ' || SQLERRM); RAISE;
  end;

  begin
    execute immediate 'revoke execute on ORDMD_IDX_LIBS from public';
    exception
      when package_not_found then NULL;
      when already_revoked then NULL;
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')17]: ' || SQLERRM); RAISE;
  end;

  begin
    execute immediate 'revoke execute on ORDMD_GMD_LIBS from public';
    exception
      when package_not_found then NULL;
      when already_revoked then NULL;
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')18]: ' || SQLERRM); RAISE;
  end;

  begin
    execute immediate 'revoke execute on ORDMD_TNPC_LIBS from public';
    exception
      when package_not_found then NULL;
      when already_revoked then NULL;
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')19]: ' || SQLERRM); RAISE;
  end;

  begin
    execute immediate 'drop trigger SDO_DROP_USER_BEFORE ';
    exception
      when others then return;
  end;

  begin
    execute immediate 'drop trigger SDO_NETWORK_CONS_DROP_TRIG ';
    exception
      when others then return;
  end;

  begin
    execute immediate 'drop trigger SDO_NETWORK_UD_DROP_TRIG ';
    exception
      when others then return;
  end;

  begin
    execute immediate 'drop public synonym SDO_GET_ITYP_NAME ';
    exception
      when others then return;
  end;

  begin
    execute immediate 'drop function MDSYS.SDO_GET_ITYP_NAME ';
    exception
      when others then return;
  end;
end;
/




-- drop the temporary index_method if it exists
prompt declare#2
declare
begin
   begin
      execute immediate ' drop type sdo_index_method_temp force ';
      exception
       when others then return;
   end;

end;
/

prompt declare#3
declare
begin
   begin
      execute immediate ' drop type SDO_CART_TEXT force ';
      execute immediate ' drop public synonym SDO_CART_TEXT force ';
      exception
       when others then return;
   end;

end;
/




create type sdo_index_method_temp as object
 ( scan_ctx raw(4) ,
     STATIC function ODCIGetInterfaces(ifclist OUT sys.ODCIObjectList)
         return number );
/

create or replace type body sdo_index_method_temp
is
  STATIC function ODCIGetInterfaces(ifclist OUT sys.ODCIObjectList)
         return number is
   begin
       ifclist := sys.ODCIObjectList(sys.ODCIObject('SYS','ODCIINDEX2'));
       return ODCIConst.Success;
   end ODCIGetInterfaces;
end;
/

prompt declare#4
declare
  object_not_found exception;
  pragma exception_init(object_not_found, -04043);
  object_not_found_2 exception;
  pragma exception_init(object_not_found_2, -29816);
  assoc_not_found exception;
  pragma exception_init(assoc_not_found, -29931);
begin
   begin
     execute immediate
  ' alter type sdo_index_method_10i compile specification reuse settings ';
     exception
       when object_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')20]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate
  ' alter type sdo_index_method_9i compile specification reuse settings ';
     exception
       when object_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')21]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate
  ' alter type sdo_index_method compile specification reuse settings ';
     exception
       when object_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')22]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate
  ' alter type RTREE_INDEX_METHOD compile specification reuse settings ';
      exception
        when object_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                 'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')23]: ' || SQLERRM); RAISE;
   end;

-- drop the old methods from statistics type
  begin
    begin
      execute immediate
       'DISASSOCIATE STATISTICS FROM INDEXTYPES spatial_index FORCE' ;
      exception
        when assoc_not_found then NULL;
        when object_not_found_2 then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                 'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')24]: ' || SQLERRM); RAISE;
    end;

    begin
      execute immediate
       'DISASSOCIATE STATISTICS FROM INDEXTYPES spatial_index_v2 FORCE' ;
      exception
        when assoc_not_found then NULL;
        when object_not_found_2 then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                 'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')24]: ' || SQLERRM); RAISE;
    end;


    begin
      execute immediate
        'DISASSOCIATE STATISTICS FROM PACKAGES sdo_3gl FORCE ';
      exception
        when assoc_not_found then NULL;
        when object_not_found_2 then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                 'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')24]: ' || SQLERRM); RAISE;
    end;

    begin
      execute immediate
        'DISASSOCIATE STATISTICS FROM PACKAGES prvt_idx FORCE ';
      exception
        when assoc_not_found then NULL;
        when object_not_found_2 then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                 'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')24]: ' || SQLERRM); RAISE;
    end;
  end;

  begin
    execute immediate
       ' alter type sdo_statistics drop ' ||
       ' STATIC FUNCTION ODCIStatsCollect(ia sys.ODCIIndexInfo, ' ||
       ' options sys.ODCIStatsOptions, rawstats OUT RAW, env sys.ODCIEnv) ' ||
       ' RETURN NUMBER CASCADE';
    exception
      when object_not_found then NULL;
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')25]: ' || SQLERRM); RAISE;
  end;

  begin
    execute immediate
       ' alter type sdo_statistics drop ' ||
       ' STATIC FUNCTION ODCIStatsDelete(ia sys.ODCIIndexInfo, ' ||
       ' rawstats OUT RAW, env sys.ODCIEnv) ' ||
       ' RETURN NUMBER CASCADE';
    exception
      when object_not_found then NULL;
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')26]: ' || SQLERRM); RAISE;
  end;

  begin
    execute immediate ' drop type sdo_statistics ';
    exception
      when object_not_found then NULL;
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')27]: ' || SQLERRM); RAISE;
  end;

end;
/


prompt declare#5
-- ignore exceptions here as we don't know the state of the operators
-- when it comes to this step. They might be in invalid state so we can
-- safely ignore the compile errors as we will recrete them later anyway

declare
  operator_not_found exception;
  pragma exception_init(operator_not_found, -29807);
begin
   begin
      execute immediate ' alter operator LOCATOR_WITHIN_DISTANCE compile ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                             'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')28]: ' || SQLERRM); 
   end;

   begin
      execute immediate ' alter operator RTREE_FILTER compile ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                             'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')29]: ' || SQLERRM); 
   end;

   begin
      execute immediate ' alter operator RTREE_NN compile ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                             'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')30]: ' || SQLERRM); 
   end;

   begin
      execute immediate ' alter operator SDO_FILTER compile ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                             'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')31]: ' || SQLERRM); 
   end;

   begin
      execute immediate ' alter operator SDO_INT2_FILTER compile ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                             'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')32]: ' || SQLERRM); 
   end;

   begin
      execute immediate ' alter operator SDO_INT2_RELATE compile ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                             'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')33]: ' || SQLERRM); 
   end;

   begin
      execute immediate '  alter operator SDO_INT_FILTER compile ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                             'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')34]: ' || SQLERRM); 
   end;

   begin
      execute immediate ' alter operator SDO_INT_RELATE compile ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                             'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')35]: ' || SQLERRM); 
   end;

   begin
      execute immediate ' alter operator SDO_NN compile ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                             'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')36]: ' || SQLERRM); 
   end;

   begin
      execute immediate ' alter operator SDO_NN_DISTANCE compile ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                             'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')37]: ' || SQLERRM); 
   end;

   begin
      execute immediate ' alter operator SDO_RELATE compile ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')38]: ' || SQLERRM); 
   end;

   begin
      execute immediate ' alter operator SDO_RTREE_FILTER compile ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')39]: ' || SQLERRM); 
   end;

   begin
      execute immediate ' alter operator SDO_RTREE_RELATE compile ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')40]: ' || SQLERRM); 
   end;

   begin
      execute immediate ' alter operator SDO_WITHIN_DISTANCE compile ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')41]: ' || SQLERRM); 
   end;
end;
/


-- ignore exceptions here also as the operators might be in invalid state
prompt declare#6
declare
  operator_not_found exception;
  pragma exception_init(operator_not_found, -29807);
begin
   begin
     execute immediate
         ' alter indextype spatial_index using sdo_index_method_temp
            WITH LOCAL range PARTITION ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')42]: ' || SQLERRM); 
   end;
end;
/



prompt declare#7
declare
begin
   begin
      execute immediate ' drop function sdo_dummy_function ';
      exception
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')43]: ' || SQLERRM); RAISE;
   end;
end;
/

create function sdo_dummy_function (geom1 IN mdsys.sdo_geometry,
                             geom2 IN mdsys.sdo_geometry, param IN varchar2)
return varchar2 is
begin
  return 'DUMMY';
end;
/
grant execute on sdo_dummy_function to public;

prompt declare#8
declare
  operator_depend exception;
  pragma exception_init(operator_depend, -29809);
begin
   begin
      execute immediate ' drop operator sdo_dummy ';
      exception
        when operator_depend then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                 'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')44]: ' || SQLERRM); RAISE;
   end;
end;
/


prompt declare#9
declare
  name_already_used exception;
  pragma exception_init(name_already_used, -00955);
begin
   begin
      execute immediate
  'create  operator
   sdo_dummy binding (mdsys.sdo_geometry, mdsys.sdo_geometry, varchar2)
  return varchar2 using sdo_dummy_function ';
      exception
        when name_already_used then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                 'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')45]: ' || SQLERRM); RAISE;
   end;
end;
/

grant execute on sdo_dummy to public;


-- add dummy operator to spatial_index indextype
-- ignore exception here as the operators might in invalid state
-- in cdb/pdb case the exception needs to be NULL
prompt declare#10
declare
  duplicate_operator exception;
  pragma exception_init(duplicate_operator, -29844);
  operator_not_found exception;
  pragma exception_init(operator_not_found, -29807);
begin
   begin
      execute immediate
  'alter indextype spatial_index
   add sdo_dummy(mdsys.sdo_geometry, mdsys.sdo_geometry, varchar2) ';
      exception
        when duplicate_operator then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                 'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')46]: ' || SQLERRM); 
   end;
end;
/


-- drop all the operators associated with the indextype
-- ignore exception here as the operators might in invalid state
prompt declare#11
declare
  operator_not_found exception;
  pragma exception_init(operator_not_found, -29830);
begin
   begin
      execute immediate
 ' alter indextype spatial_index
drop sdo_nn_distance(number) ' ;
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                 'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')47]: ' || SQLERRM); 
   end;

   begin
      execute immediate
  'alter indextype spatial_index drop
  sdo_nn(mdsys.sdo_geometry, mdsys.sdo_geometry, varchar2) ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')48]: ' || SQLERRM); 
   end;

   begin
      execute immediate
  ' alter indextype spatial_index drop
   sdo_relate(mdsys.sdo_geometry, mdsys.sdo_geometry, varchar2) ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')49]: ' || SQLERRM); 
   end;

   begin
      execute immediate
  ' alter indextype spatial_index drop
    sdo_anyinteract(mdsys.sdo_geometry, mdsys.sdo_geometry) ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')50]: ' || SQLERRM); 
   end;

   begin
      execute immediate
   ' alter indextype spatial_index drop
     sdo_anyinteract(mdsys.sdo_topo_geometry, mdsys.sdo_topo_geometry) ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')51]: ' || SQLERRM); 
   end;

   begin
      execute immediate
   ' alter indextype spatial_index drop
     sdo_anyinteract(mdsys.sdo_topo_geometry, mdsys.sdo_geometry) ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')52]: ' || SQLERRM); 
   end;

   begin
      execute immediate
   ' alter indextype spatial_index drop
     sdo_contains(mdsys.sdo_geometry, mdsys.sdo_geometry) ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')53]: ' || SQLERRM); 
   end;

   begin
      execute immediate
   ' alter indextype spatial_index drop
     sdo_inside(mdsys.sdo_geometry, mdsys.sdo_geometry) ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')54]: ' || SQLERRM); 
   end;

   begin
      execute immediate
   ' alter indextype spatial_index drop
     sdo_touch(mdsys.sdo_geometry, mdsys.sdo_geometry) ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')55]: ' || SQLERRM); 
   end;

   begin
      execute immediate
   ' alter indextype spatial_index drop
     sdo_equal(mdsys.sdo_geometry, mdsys.sdo_geometry) ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')56]: ' || SQLERRM); 
   end;

   begin
      execute immediate
   ' alter indextype spatial_index drop
     sdo_covers(mdsys.sdo_geometry, mdsys.sdo_geometry) ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')57]: ' || SQLERRM); 
   end;

   begin
      execute immediate
   ' alter indextype spatial_index drop
     sdo_coveredby(mdsys.sdo_geometry, mdsys.sdo_geometry) ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')58]: ' || SQLERRM); 
   end;

   begin
      execute immediate
   ' alter indextype spatial_index drop
     sdo_overlaps(mdsys.sdo_geometry, mdsys.sdo_geometry) ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')59]: ' || SQLERRM); 
   end;

   begin
      execute immediate
    ' alter indextype spatial_index drop
      sdo_on(mdsys.sdo_geometry, mdsys.sdo_geometry) ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')60]: ' || SQLERRM); 
   end;

   begin
      execute immediate
    ' alter indextype spatial_index drop
     sdo_overlapbdydisjoint(mdsys.sdo_geometry, mdsys.sdo_geometry) ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                             'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')61]: ' || SQLERRM); 
   end;

   begin
      execute immediate
  ' alter indextype spatial_index drop
   sdo_overlapbdyintersect(mdsys.sdo_geometry, mdsys.sdo_geometry) ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')62]: ' || SQLERRM); 
   end;

   begin
      execute immediate
  ' alter indextype spatial_index drop
    sdo_filter(mdsys.sdo_geometry, mdsys.sdo_geometry, varchar2) ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')63]: ' || SQLERRM); 
   end;

   begin
      execute immediate
   ' alter indextype spatial_index drop
    sdo_rtree_relate(mdsys.sdo_geometry, mdsys.sdo_geometry, varchar2) ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')64]: ' || SQLERRM); 
   end;

   begin
      execute immediate
   ' alter indextype spatial_index drop
    sdo_rtree_filter(mdsys.sdo_geometry, mdsys.sdo_geometry, varchar2) ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')65]: ' || SQLERRM); 
   end;

   begin
      execute immediate
  ' alter indextype spatial_index drop
  sdo_int_relate(mdsys.sdo_geometry, mdsys.sdo_geometry, varchar2, varchar2,
               varchar2, varchar2,number,number, number) ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')66]: ' || SQLERRM); 
   end;

   begin
      execute immediate
   ' alter indextype spatial_index drop
   sdo_int_filter(mdsys.sdo_geometry, mdsys.sdo_geometry, varchar2, varchar2,
               varchar2, varchar2,number,number, number) ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')67]: ' || SQLERRM); 
   end;

   begin
      execute immediate
  ' alter indextype spatial_index drop
   sdo_within_distance(mdsys.sdo_geometry, mdsys.sdo_geometry, varchar2) ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')68]: ' || SQLERRM); 
   end;

   begin
      execute immediate
  ' alter indextype spatial_index drop
  locator_within_distance(mdsys.sdo_geometry, mdsys.sdo_geometry, varchar2)' ;
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')69]: ' || SQLERRM); 
   end;

   begin
      execute immediate
  ' alter indextype spatial_index drop
  sdo_int2_relate(mdsys.sdo_geometry, mdsys.sdo_geometry, varchar2) ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')70]: ' || SQLERRM); 
   end;

   begin
      execute immediate
  ' alter indextype spatial_index drop
  sdo_int2_filter(mdsys.sdo_geometry, mdsys.sdo_geometry, varchar2)' ;
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')71]: ' || SQLERRM); 
   end;

end;
/

-- drop operators from spatial_index_v2
-- dif in lrgsrgdbcuplg with the exception RAISE
prompt declare#12
declare
  indextype_not_found exception;
  pragma exception_init(indextype_not_found, -29833);
begin
   begin
     execute immediate
         ' alter indextype spatial_index_v2 using sdo_index_method_temp
            WITH LOCAL range PARTITION ';
     exception
       when indextype_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                            'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')72]: ' || SQLERRM); 
   end;
end;
/


prompt declare#13
declare
  object_not_found exception;
  pragma exception_init(object_not_found, -04043);
begin
   begin
      execute immediate ' drop function sdo_dummy_function_v2 ';
      exception
        when object_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                 'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')73]: ' || SQLERRM); RAISE;
   end;
end;
/

create function sdo_dummy_function_v2 (geom1 IN mdsys.sdo_geometry,
                             geom2 IN mdsys.sdo_geometry, param IN varchar2)
return varchar2 is
begin
  return 'DUMMY';
end;
/
grant execute on sdo_dummy_function_v2 to public;

prompt declare#14
declare
  operator_not_found exception;
  pragma exception_init(operator_not_found, -29807);
begin
   begin
      execute immediate ' drop operator sdo_dummy_2 ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                 'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')74]: ' || SQLERRM); RAISE;
   end;
end;
/


prompt declare#15
declare
begin
   begin
      execute immediate
  'create operator
   sdo_dummy_v2 binding (mdsys.sdo_geometry, mdsys.sdo_geometry, varchar2)
  return varchar2 using sdo_dummy_function_v2 ';
      exception
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')75]: ' || SQLERRM); RAISE;
   end;
end;
/

grant execute on sdo_dummy_v2 to public;


-- add dummy operator to spatial_index_v2 indextype
-- error in lrgsrgdbcuplg with RAISE
prompt declare#16
declare
  indextype_not_found exception;
  pragma exception_init(indextype_not_found, -29833);
begin
   begin
      execute immediate
  'alter indextype spatial_index_v2
   add sdo_dummy_v2(mdsys.sdo_geometry, mdsys.sdo_geometry, varchar2) ';
      exception
        when indextype_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                 'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')76]: ' || SQLERRM); 
   end;
end;
/


-- drop all the operators associated with the indextype
-- error in lrgsrgdbcuplg with RAISE
prompt declare#17
declare
  indextype_not_found exception;
  pragma exception_init(indextype_not_found, -29833);
begin
   begin
      execute immediate
 ' alter indextype spatial_index_v2
drop sdo_nn_distance(number) ' ;
      exception
        when indextype_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')77]: ' || SQLERRM); 
   end;

   begin
      execute immediate
  'alter indextype spatial_index_v2 drop
  sdo_nn(mdsys.sdo_geometry, mdsys.sdo_geometry, varchar2) ';
      exception
        when indextype_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')78]: ' || SQLERRM); 
   end;

   begin
      execute immediate
  ' alter indextype spatial_index_v2 drop
   sdo_relate(mdsys.sdo_geometry, mdsys.sdo_geometry, varchar2) ';
      exception
        when indextype_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')79]: ' || SQLERRM); 
   end;

   begin
      execute immediate
  ' alter indextype spatial_index_v2 drop
    sdo_anyinteract(mdsys.sdo_geometry, mdsys.sdo_geometry) ';
      exception
        when indextype_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')80]: ' || SQLERRM); 
   end;

   begin
      execute immediate
   ' alter indextype spatial_index_v2 drop
     sdo_anyinteract(mdsys.sdo_topo_geometry, mdsys.sdo_topo_geometry) ';
      exception
        when indextype_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')81]: ' || SQLERRM); 
   end;

   begin
      execute immediate
   ' alter indextype spatial_index_v2 drop
     sdo_anyinteract(mdsys.sdo_topo_geometry, mdsys.sdo_geometry) ';
      exception
        when indextype_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')82]: ' || SQLERRM); 
   end;

   begin
      execute immediate
   ' alter indextype spatial_index_v2 drop
     sdo_contains(mdsys.sdo_geometry, mdsys.sdo_geometry) ';
      exception
        when indextype_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')83]: ' || SQLERRM); 
   end;

   begin
      execute immediate
   ' alter indextype spatial_index_v2 drop
     sdo_inside(mdsys.sdo_geometry, mdsys.sdo_geometry) ';
      exception
        when indextype_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')84]: ' || SQLERRM); 
   end;

   begin
      execute immediate
   ' alter indextype spatial_index_v2 drop
     sdo_touch(mdsys.sdo_geometry, mdsys.sdo_geometry) ';
      exception
        when indextype_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')85]: ' || SQLERRM); 
   end;

   begin
      execute immediate
   ' alter indextype spatial_index_v2 drop
     sdo_equal(mdsys.sdo_geometry, mdsys.sdo_geometry) ';
      exception
        when indextype_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')86]: ' || SQLERRM); 
   end;

   begin
      execute immediate
   ' alter indextype spatial_index_v2 drop
     sdo_covers(mdsys.sdo_geometry, mdsys.sdo_geometry) ';
      exception
        when indextype_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')87]: ' || SQLERRM); 
   end;

   begin
      execute immediate
   ' alter indextype spatial_index_v2 drop
     sdo_coveredby(mdsys.sdo_geometry, mdsys.sdo_geometry) ';
      exception
        when indextype_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')88]: ' || SQLERRM); 
   end;

   begin
      execute immediate
   ' alter indextype spatial_index_v2 drop
     sdo_overlaps(mdsys.sdo_geometry, mdsys.sdo_geometry) ';
      exception
        when indextype_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')89]: ' || SQLERRM); 
   end;

   begin
      execute immediate
    ' alter indextype spatial_index_v2 drop
      sdo_on(mdsys.sdo_geometry, mdsys.sdo_geometry) ';
      exception
        when indextype_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')90]: ' || SQLERRM); 
   end;

   begin
      execute immediate
    ' alter indextype spatial_index_v2 drop
     sdo_overlapbdydisjoint(mdsys.sdo_geometry, mdsys.sdo_geometry) ';
      exception
        when indextype_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')91]: ' || SQLERRM); 
   end;

   begin
      execute immediate
  ' alter indextype spatial_index_v2 drop
   sdo_overlapbdyintersect(mdsys.sdo_geometry, mdsys.sdo_geometry) ';
      exception
        when indextype_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')92]: ' || SQLERRM); 
   end;

   begin
      execute immediate
  ' alter indextype spatial_index_v2 drop
    sdo_filter(mdsys.sdo_geometry, mdsys.sdo_geometry, varchar2) ';
      exception
        when indextype_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')93]: ' || SQLERRM); 
   end;

   begin
      execute immediate
   ' alter indextype spatial_index_v2 drop
    sdo_rtree_relate(mdsys.sdo_geometry, mdsys.sdo_geometry, varchar2) ';
      exception
        when indextype_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')94]: ' || SQLERRM); 
   end;

   begin
      execute immediate
   ' alter indextype spatial_index_v2 drop
    sdo_rtree_filter(mdsys.sdo_geometry, mdsys.sdo_geometry, varchar2) ';
      exception
        when indextype_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')95]: ' || SQLERRM); 
   end;

   begin
      execute immediate
  ' alter indextype spatial_index_v2 drop
  sdo_int_relate(mdsys.sdo_geometry, mdsys.sdo_geometry, varchar2, varchar2,
               varchar2, varchar2,number,number, number) ';
      exception
        when indextype_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')96]: ' || SQLERRM); 
   end;

   begin
      execute immediate
   ' alter indextype spatial_index_v2 drop
   sdo_int_filter(mdsys.sdo_geometry, mdsys.sdo_geometry, varchar2, varchar2,
               varchar2, varchar2,number,number, number) ';
      exception
        when indextype_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')97]: ' || SQLERRM); 
   end;

   begin
      execute immediate
  ' alter indextype spatial_index_v2 drop
   sdo_within_distance(mdsys.sdo_geometry, mdsys.sdo_geometry, varchar2) ';
      exception
        when indextype_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')98]: ' || SQLERRM); 
   end;

   begin
      execute immediate
  ' alter indextype spatial_index_v2 drop
  locator_within_distance(mdsys.sdo_geometry, mdsys.sdo_geometry, varchar2)' ;
      exception
        when indextype_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')99]: ' || SQLERRM); 
   end;

   begin
      execute immediate
  ' alter indextype spatial_index_v2 drop
  sdo_int2_relate(mdsys.sdo_geometry, mdsys.sdo_geometry, varchar2) ';
      exception
        when indextype_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')100]: ' || SQLERRM); 
   end;

   begin
      execute immediate
  ' alter indextype spatial_index_v2 drop
  sdo_int2_filter(mdsys.sdo_geometry, mdsys.sdo_geometry, varchar2)' ;
      exception
        when indextype_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')101]: ' || SQLERRM); 
   end;

end;
/




prompt declare#18
declare
  operator_not_found exception;
  pragma exception_init(operator_not_found, -29807);
begin
   begin
      execute immediate ' drop operator sdo_nn force ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                 'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')102]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop operator sdo_nn_distance force ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')103]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop operator sdo_filter force ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                 'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')104]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop operator sdo_int2_filter force  ';
     exception
       when operator_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')105]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop operator sdo_int_filter force ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                 'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')106]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop operator sdo_relate force ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')107]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop operator sdo_int2_relate force ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')108]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop operator sdo_int_relate force ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')109]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop operator sdo_rtree_filter force ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')110]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop operator sdo_rtree_relate force ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')111]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop operator sdo_within_distance force ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')112]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop operator locator_within_distance force ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')113]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop operator sdo_anyinteract force ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')114]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop operator sdo_contains force ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')115]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop operator sdo_inside force ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')116]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop operator sdo_touch force ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')117]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop operator sdo_equal force ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')118]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop operator sdo_covers force ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')119]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop operator sdo_on force ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')120]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop operator sdo_coveredby force ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')121]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop operator sdo_overlapbdydisjoint force ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')122]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop operator sdo_overlapbdyintersect force ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')123]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop operator sdo_overlaps force ';
      exception
        when operator_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')124]: ' || SQLERRM); RAISE;
   end;
end;
/

prompt declare#19
declare
  object_not_found exception;
  pragma exception_init(object_not_found, -04043);
begin
   begin
      execute immediate ' drop type SDO_INDEX_METHOD_9I ';
      exception
        when object_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                 'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')125]: ' || SQLERRM); RAISE;
   end;
end;
/

prompt declare#20
declare
  object_not_found exception;
  pragma exception_init(object_not_found, -04043);
begin
   begin
      execute immediate ' drop type SDO_INDEX_METHOD ';
      exception
        when object_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')126]: ' || SQLERRM); RAISE;
   end;
end;
/

prompt declare#21
declare
  object_not_found exception;
  pragma exception_init(object_not_found, -04043);
  dependent_object exception;
  pragma exception_init(dependent_object, -02303);
begin
   begin
      execute immediate ' drop type SDO_INDEX_METHOD_10I ';
      exception
        when object_not_found then NULL;
        when dependent_object then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')127]: ' || SQLERRM); RAISE;
   end;
end;
/

prompt declare#22
declare
  object_not_found exception;
  pragma exception_init(object_not_found, -04043);
begin
  execute immediate 'drop package prvt_idx';
  exception
    when object_not_found then NULL;
    when others then
      SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                         'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')127]: ' || SQLERRM); RAISE;
end;
/

prompt declare#23
declare
  object_not_found exception;
  pragma exception_init(object_not_found, -04043);
begin
  execute immediate 'drop package sdo_3gl';
  exception
    when object_not_found then NULL;
    when others then
      SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                         'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')127]: ' || SQLERRM); RAISE;
end;
/


REM drop the ST_Types only if they do not have the right TOID
COLUMN :script_name NEW_VALUE comp_file NOPRINT
Variable script_name varchar2(50)
Variable sdo_cnt  number;

begin
  select count(*) into :sdo_cnt from all_types where owner='MDSYS' and
  type_name = 'ST_GEOMETRY' and type_oid = '4BA3494AB3EEE5B6E040578CB2057856';
  if (:sdo_cnt = 0) then
    :script_name := '?/md/admin/sdomsttp.sql';
  else
    :script_name := '?/rdbms/admin/nothing.sql';
  end if;
end;
/

select :script_name from SYS.DUAL;
@&comp_file


prompt declare#24
declare
  object_not_found exception;
  pragma exception_init(object_not_found, -04043);
  trigger_not_found exception;
  pragma exception_init(trigger_not_found, -04080);
begin
   begin
      execute immediate ' drop type GEOCODE_RESULT ';
      exception
        when object_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                 'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')128]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop type ROADREC force ';
      exception
        when object_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')129]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop trigger SDO_CACHED_MAP_DROP_USER ';
      exception
        when trigger_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')130]: ' || SQLERRM); RAISE;
   end;
end;
/

prompt declare#25
declare
  object_not_found exception;
  pragma exception_init(object_not_found, -04043);
begin
   begin
      execute immediate ' drop package GEOCODER_HTTP ';
      exception
        when object_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                 'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')131]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop package SDO_CMT_CBK ';
      exception
        when object_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')132]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop package PRVT_CMT_CBK ';
      exception
        when object_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')133]: ' || SQLERRM); RAISE;
   end;
end;
/

Rem =======================================================================
Rem Drop prvtccbk and sdoccbk related objects
Rem =======================================================================

declare
  trigger_not_found exception;
  pragma exception_init(trigger_not_found, -04080);
begin
  execute immediate 'drop trigger sdo_cmt_cbk_trig';
  exception
    when trigger_not_found then NULL;
    when others then
      SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                            'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')1330]: ' || SQLERRM); RAISE;
end;
/

declare
  table_not_found exception;
  pragma exception_init(table_not_found, -00942);
begin
  execute immediate 'drop table sdo_cmt_cbk_fn_table';
  exception
    when table_not_found then return;
    when others then
      SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                            'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')1331]: ' || SQLERRM); RAISE;
end;
/

declare
  table_not_found exception;
  pragma exception_init(table_not_found, -00942);
begin
  execute immediate 'drop table sdo_cmt_cbk_dml_table';
  exception
    when table_not_found then return;
    when others then
      SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                            'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')1331]: ' || SQLERRM); RAISE;
end;
/

declare
  table_not_found exception;
  pragma exception_init(table_not_found, -00942);
begin
  execute immediate 'drop table sdo_cmt_cbk_rtree_tab';
  exception
    when table_not_found then return;
    when others then
      SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                            'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')1332]: ' || SQLERRM); RAISE;
end;
/

begin
  execute immediate 'delete from mdsys.sdo_geom_metadata_table where ' ||
    ' sdo_owner = ''MDSYS'' and sdo_table_name = ''SDO_CMT_CBK_RTREE_TAB'' '||
    ' and sdo_column_name = ''GEOM'' ';

  exception
    when others then
      return;
end;
/

begin
  execute immediate 'drop sequence sdo_cmt_cbk_txn_order';

  exception
    when others then
      return;
end;
/

prompt declare#26
declare
  view_not_found exception;
  pragma exception_init(view_not_found, -00942);
  synonym_not_found exception;
  pragma exception_init(synonym_not_found, -01432);
begin
  begin
    begin
      execute immediate ' drop view MDSYS.DBA_SDO_INDEX_METADATA ';
      exception
        when view_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                 'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')1341]: ' || SQLERRM); RAISE;
    end;

    begin
      execute immediate ' drop view MDSYS.DBA_SDO_GEOM_METADATA ';
      exception
        when view_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                 'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')1342]: ' || SQLERRM); RAISE;
    end;

    begin
      execute immediate ' drop view MDSYS.DBA_SDO_INDEX_INFO ';
      exception
        when view_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                 'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')1343]: ' || SQLERRM); RAISE;
    end;
  end;

  begin
    begin
      execute immediate ' drop public synonym DBA_SDO_INDEX_METADATA ';
      exception
        when synonym_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                 'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')1342]: ' || SQLERRM); RAISE;
    end;

    begin
      execute immediate ' drop public synonym DBA_SDO_INDEX_INFO ';
      exception
        when synonym_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                 'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')1342]: ' || SQLERRM); RAISE;
    end;

    begin
      execute immediate ' drop public synonym DBA_SDO_GEOM_METADATA ';
      exception
        when synonym_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                 'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')135]: ' || SQLERRM); RAISE;
    end;
  end;
end;
/

prompt declare#27
declare
  object_not_found exception;
  pragma exception_init(object_not_found, -04043);
begin
   begin
      execute immediate ' drop package mdexec ';
      exception
        when object_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                 'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')136]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop package mdexex ';
      exception
        when object_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')137]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop package mdtrig ';
      exception
        when object_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')138]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop package mdverify ';
      exception
        when object_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')139]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop package md_ddl ';
      exception
        when object_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')140]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop package md_dml ';
      exception
        when object_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')141]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop package md_part ';
      exception
        when object_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')142]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop package serv_part ';
      exception
        when object_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')143]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop package mdgen ';
      exception
        when object_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')144]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop package MDLEXR ';
      exception
        when object_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')145]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop package mddict ';
      exception
        when object_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')146]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop package mdlib ';
      exception
        when object_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')147]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop package mddict ';
      exception
        when object_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')148]: ' || SQLERRM); RAISE;
   end;


   begin
      execute immediate ' drop package mdbootstrap ';
      exception
        when object_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')149]: ' || SQLERRM); RAISE;
   end;

end;
/


prompt declare#29
declare
  table_not_found exception;
  pragma exception_init(table_not_found, -00942);
  trigger_not_found exception;
  pragma exception_init(trigger_not_found, -04080);
  primary_key_referenced exception;
  pragma exception_init(primary_key_referenced, -02449);
begin
   begin
      execute immediate ' drop table SDO_DATUMS ';
      exception
        when primary_key_referenced then NULL;
        when table_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                 'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')150]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop table SDO_ELLIPSOIDS ';
      exception
        when primary_key_referenced then NULL;
        when table_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')151]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop table SDO_PROJECTIONS ';
      exception
        when table_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')152]: ' || SQLERRM); RAISE;
   end;

   begin
      execute immediate ' drop trigger SDO_NETWORK_LOCKS_DROP_TRIG  ';
      exception
        when trigger_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                 'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')153]: ' || SQLERRM); RAISE;
   end;

end;
/

prompt declare#30
declare
begin
   begin
     execute immediate ' PURGE TABLESPACE SYSTEM USER MDSYS  ';
     execute immediate ' PURGE TABLESPACE SYSAUX USER MDSYS  ';
           exception
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')154]: ' || SQLERRM); RAISE;
   end;
end;
/

prompt declare#31
declare
stmt varchar2(2000);
begin

 begin
 stmt := ' create table mdsys.cs_srs_orig as select * from mdsys.cs_Srs';
 execute immediate stmt;
 stmt := 'drop table mdsys.cs_srs';
 execute immediate stmt;
 exception
  when others then
    return;
 end;
end;
/

prompt declare#32
declare
  view_not_found exception;
  pragma exception_init(view_not_found, -00942);
  synonym_not_found exception;
  pragma exception_init(synonym_not_found, -01432);
  object_not_found exception;
  pragma exception_init(object_not_found, -04043);
begin
   begin
     execute immediate ' PURGE TABLESPACE SYSTEM USER MDSYS  ';
     execute immediate ' PURGE TABLESPACE SYSAUX USER MDSYS  ';
           exception
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')155]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' DROP VIEW MDSYS.DBA_SDO_LRS_METADATA ';
     exception
       when view_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')156]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' DROP public synonym DBA_SDO_LRS_METADATA ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                               'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')157]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' DROP TYPE SDO_RID_ARRAY FORCE ';
     exception
       when object_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')158]: ' || SQLERRM); RAISE;
   end;
end;
/


prompt declare#33
declare
  object_not_found exception;
  pragma exception_init(object_not_found, -04043);
begin
  begin
    execute immediate ' drop procedure MDSYS.validate_sdo ';
    exception
      when object_not_found then NULL;
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')159]: ' || SQLERRM); RAISE;
   end;
end;
/

prompt declare#34
declare
  synonym_not_found exception;
  pragma exception_init(synonym_not_found, -01432);
begin
  begin
    execute immediate ' drop public synonym HHIDLROWS ';
    exception
      when synonym_not_found then NULL;
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')160]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym SDO_COMPARE  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')161]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym SDO_LATLONTOCODE  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')162]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym SDO_DATETODIM  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')163]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym SDO_BVALUETODIM  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')164]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym SDO_HVALUETODIM  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')165]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym SDO_ENCODE  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')166]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym SDO_DECODE  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')167]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym SDO_TO_LAT  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')168]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym SDO_TO_LON  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')169]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym SDO_TO_DATE  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')170]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym SDO_TO_BVALUE  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')171]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym SDO_TO_HVALUE  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')172]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHNDIM  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')173]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHLENGTH  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')174]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHLINEOR  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')175]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHBYTELEN  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')176]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHPRECISION  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')177]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHLEVELS  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')178]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHENCODE  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')179]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHDECODE  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')180]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHCELLBNDRY  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')181]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHCELLSIZE  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')182]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHSUBSTR  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')183]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHCOLLAPSE  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')184]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHCOMPOSE  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')185]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHNEIGHBOUR  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')186]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHCOMMONCODE  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')187]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHMATCH  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')188]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHDISTANCE  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')189]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHORDER  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')190]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHGROUP  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')191]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHJLDATE  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')192]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHCLDATE  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')193]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHIDPART  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')194]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHIDLPART  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')195]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHIDROWS  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')196]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHIDLROWS  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')197]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHNCOMPARE  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')198]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHCOMPARE  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')199]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHAND  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')200]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHOR  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')201]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHXOR  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')202]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHBITS  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')203]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHGETCID  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')204]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHSTBIT  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')205]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHGTBIT  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')206]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHSTYPE  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')207]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHGTYPE  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')208]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHSBIT  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')209]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHCBIT  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')210]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHGBIT  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')211]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHINCRLEV  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')212]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop public synonym HHLINEPS  ';
     exception
       when synonym_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')213]: ' || SQLERRM); RAISE;
   end;

end;
/

prompt declare#35
declare
  object_not_found exception;
  pragma exception_init(object_not_found, -04043);
begin
  begin
    execute immediate ' drop package VALUE$CACHE ';
    exception
     when object_not_found then NULL;
     when others then
       SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                              'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')214]: ' || SQLERRM); RAISE;
   end;
end;
/

prompt declare#36
declare
  object_not_found exception;
  pragma exception_init(object_not_found, -04043);
begin
  execute immediate 'drop type body SDO_TOPO_GEOMETRY';
  exception
    when object_not_found then NULL;
    when others then
      SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                             'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')214]: ' || SQLERRM); RAISE;
end;
/

prompt declare#37
declare
begin
 begin
  execute immediate
   ' alter type sdo_topo_geometry drop
    Constructor Function SDO_Topo_Geometry( topology varchar2,
                                    TG_Type number,
                                    TG_layer_id NUMBER,
                                    Topo_ids SDO_TOPO_OBJECT_ARRAY)
     return SELF as RESULT DETERMINISTIC CASCADE ';

  execute immediate
   ' alter type sdo_topo_geometry drop
   Constructor Function SDO_Topo_Geometry( topology varchar2,
                                    TG_Type number,
                                    TG_layer_id NUMBER,
                                    add_Topo_ids SDO_TOPO_OBJECT_ARRAY,
                                    delete_Topo_ids SDO_TOPO_OBJECT_ARRAY)
     return SELF as RESULT DETERMINISTIC CASCADE ';

  execute immediate
   ' alter type sdo_topo_geometry drop
   Constructor Function SDO_Topo_Geometry( topology varchar2,
                                    Table_Name  varchar2,
                                    Column_Name varchar2,
                                    TG_Type number,
                                    Topo_ids SDO_TOPO_OBJECT_ARRAY)
     return SELF as RESULT DETERMINISTIC CASCADE';

  execute immediate
   'alter type sdo_topo_geometry drop
   Constructor Function SDO_Topo_Geometry( topology varchar2,
                                    Table_Name  varchar2,
                                    Column_Name varchar2,
                                    TG_Type number,
                                    add_Topo_ids SDO_TOPO_OBJECT_ARRAY,
                                    delete_Topo_ids SDO_TOPO_OBJECT_ARRAY)
     return SELF as RESULT DETERMINISTIC CASCADE';

  execute immediate
  ' alter type sdo_topo_geometry drop
    Constructor Function SDO_Topo_Geometry(TG_ID number,  topology varchar2,
                                    TG_Type number,
                                    TG_layer_id NUMBER,
                                    Topo_ids SDO_TOPO_OBJECT_ARRAY)
     return SELF as RESULT DETERMINISTIC CASCADE';

  execute immediate
   ' alter type sdo_topo_geometry drop
   Constructor Function SDO_Topo_Geometry( TG_ID number, topology varchar2,
                                    TG_Type number,
                                    TG_layer_id NUMBER,
                                    add_Topo_ids SDO_TOPO_OBJECT_ARRAY,
                                    delete_Topo_ids SDO_TOPO_OBJECT_ARRAY)
     return SELF as RESULT DETERMINISTIC CASCADE';

  execute immediate
   ' alter type sdo_topo_geometry drop
   Constructor Function SDO_Topo_Geometry(TG_ID number,  topology varchar2,
                                    Table_Name  varchar2,
                                    Column_Name varchar2,
                                    TG_Type number,
                                    Topo_ids SDO_TOPO_OBJECT_ARRAY)
     return SELF as RESULT DETERMINISTIC CASCADE';

  execute immediate
   'alter type sdo_topo_geometry drop
   Constructor Function SDO_Topo_Geometry(TG_ID number,  topology varchar2,
                                    Table_Name  varchar2,
                                    Column_Name varchar2,
                                    TG_Type number,
                                    add_Topo_ids SDO_TOPO_OBJECT_ARRAY,
                                    delete_Topo_ids SDO_TOPO_OBJECT_ARRAY)
     return SELF as RESULT DETERMINISTIC CASCADE';


  execute immediate
   ' alter type sdo_topo_geometry drop
   member  Function GET_TOPO_ELEMENTS
     return SDO_TOPO_OBJECT_ARRAY  DETERMINISTIC CASCADE';

  exception
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')216]: ' || SQLERRM); RAISE;
 end;
end;
/

prompt declare#38
declare
  object_not_found exception;
  pragma exception_init(object_not_found, -04043);
  table_not_found exception;
  pragma exception_init(table_not_found, -00942);
  indextype_not_found exception;
  pragma exception_init(indextype_not_found, -29833);
  primary_key_referenced exception;
  pragma exception_init(primary_key_referenced, -02449);
begin
   begin
     execute immediate 'drop table MDSYS.TokenSessionMap_t$';
     exception
       when primary_key_referenced then NULL;
       when table_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')217]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop indextype  mdsys.rtree_index' ;
     exception
       when indextype_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')218]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop type mdsys.rtree_index_method force';
     exception
       when object_not_found then NULL;
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')219]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate 'drop package body mdsys.RTREE_IDX';
     exception
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                                'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')220]: ' || SQLERRM); RAISE;
   end;

   begin
     execute immediate ' drop package mdsys.SDO_RTREE_ADMIN';
     exception
       when others then
         SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')221]: ' || SQLERRM); RAISE;
   end;
   begin
      execute immediate ' drop package body mdsys.sdo_tune';
       exception
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')222]: ' || SQLERRM); RAISE;
   end;
   begin
      execute immediate ' drop operator mdsys.RTREE_FILTER';
       exception
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')223]: ' || SQLERRM); RAISE;
   end;
   begin
      execute immediate ' drop operator mdsys.RTREE_nn';
       exception
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')224]: ' || SQLERRM); RAISE;
   end;
   begin
      execute immediate 'drop public synonym SDO_RTREE_ADMIN';
       exception
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')225]: ' || SQLERRM); RAISE;
   end;
end;
/


-- #21925692: Add SDO_TABLE_NAME (base table name) to the index metadata
-- table to eliminate the need for a JOIN operation on the
-- SDO_GEOM_METADATA_TABLE.
prompt declare#39
declare
  column_exists exception;
  pragma exception_init(column_exists, -01430);
begin
  begin
    execute immediate
  ' ALTER TABLE sdo_index_metadata_table ' ||
  ' ADD (SDO_TABLE_NAME VARCHAR2(130) default null)' ;
    exception
      when column_exists then NULL;
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')226]: ' || SQLERRM); RAISE;
  end;
end;
/

-- Populate the new SDO_TABLE_NAME column for all existing spatial indexes
-- IF the SDO_TABLE_NAME column is NULL
set serveroutput on
prompt declare#40
declare
  stmt1 varchar2(4000);
  stmt2 varchar2(4000);
  stmt3 varchar2(4000);
  TYPE cursor_type IS REF CURSOR;
  crs cursor_type;
  sdo_index_owner varchar2(130);
  sdo_index_name varchar2(130);
  sdo_tsname varchar2(130);
  sdo_table_name varchar2(130);
begin
  stmt1 := 'select SDO_INDEX_OWNER, SDO_INDEX_NAME, SDO_TSNAME, SDO_TABLE_NAME ' ||
           'from SDO_INDEX_METADATA_TABLE ';
  stmt2 := 'select TABLE_NAME from SYS.ALL_INDEXES ' ||
           'where OWNER = :own ' ||
           'and INDEX_NAME = :idx ' ||
           'and TABLE_OWNER = :tsnam ';
  stmt3 := 'update SDO_INDEX_METADATA_TABLE ' ||
           'set SDO_TABLE_NAME = :tab ' ||
           'where SDO_INDEX_OWNER = :own ' ||
           'and SDO_INDEX_NAME = :idx ' ||
           'and SDO_TSNAME = :tsnam ';

  dbms_output.put_line('Updating SDO_TABLE_NAME index metadata column');
  open crs for stmt1;
  LOOP
    FETCH crs into sdo_index_owner, sdo_index_name, sdo_tsname, sdo_table_name;
    EXIT when crs%NOTFOUND;

    if ( sdo_table_name is NULL ) then
      begin
        execute immediate stmt2 into sdo_table_name
        using sdo_index_owner, sdo_index_name, sdo_tsname;

        if ( sdo_table_name is not NULL ) then
          dbms_output.put_line(
            'Populating SDO_TABLE_NAME column for index ' ||
            SYS.DBMS_ASSERT.enquote_name(sdo_index_owner, false) || '.' ||
            SYS.DBMS_ASSERT.enquote_name(sdo_index_name, false));

          execute immediate stmt3
          using sdo_table_name, sdo_index_owner, sdo_index_name, sdo_tsname;
        end if;

        exception
      when others then
          dbms_output.put_line('UPDATE ERROR=' || SQLERRM);
      end;
    end if;
  END LOOP;
  close crs;
  commit;
  dbms_output.put_line('Updating SDO_TABLE_NAME index metadata complete');

  exception
      when others then
    dbms_output.put_line('FETCH ERROR=' || SQLERRM);
    if crs%ISOPEN then
      close crs;
    end if;
end;
/
set serveroutput off

/* set 3D SDO_ROOT_MBR: gtype=3008 etype=1007 */
prompt declare#41
declare
begin
 update sdo_index_metadata_table a
   set a.sdo_root_mbr =
         sdo_geometry(3008, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1007, 3),
                      a.sdo_root_mbr.SDO_ORDINATES)
   where a.sdo_root_mbr.sdo_gtype = 3003;
end;
/

-- create a dummy trigger to replace the old definition
create or replace trigger mdsys.sdo_cached_map_drop_user
after drop on DATABASE
declare
BEGIN
 return;
end;
/

drop trigger mdsys.sdo_cached_map_drop_user;

/* add the JAVA calls in sdomigj.sql */
alter session set current_schema=SYS;
COLUMN mig_java NEW_VALUE migjava_file NOPRINT;
SELECT dbms_registry.script('JAVAVM', '@sdomigj.sql') AS mig_java FROM SYS.DUAL;

alter session set current_schema=MDSYS;
@&migjava_file

/* delete WFS users/roles */
alter session set current_schema=SYS;
prompt declare#42
declare
  stmt VARCHAR2(10000);
  user_not_found exception;
  pragma exception_init(user_not_found, -01918);
  role_not_found exception;
  pragma exception_init(role_not_found, -01919);
begin
  begin
        stmt := ' drop user spatial_wfs_admin_usr cascade ';
        execute immediate stmt;
    exception
      when user_not_found then NULL;
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                               'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')227]: ' || SQLERRM); RAISE;
  end;

  begin
    stmt := 'drop role spatial_wfs_admin ';
    execute immediate stmt;
    exception
      when role_not_found then NULL;
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')228]: ' || SQLERRM); RAISE;
  end;

  begin
    stmt := 'drop role wfs_usr_role ';
    execute immediate stmt;
    exception
      when role_not_found then NULL;
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                           'EXCEPTION[sdomigrt.sql(' || $$PLSQL_LINE || ')229]: ' || SQLERRM); RAISE;
  end;
end;
/

alter session set current_schema=MDSYS;


Rem ********************************************************************
Rem #16473696: Indicate Oracle-Supplied object
@?/rdbms/admin/sqlsessend.sql
Rem ********************************************************************


OHA YOOOO