MINI MINI MANI MO

Path : /opt/oracle/product/18c/dbhomeXE/ord/im/admin/
File Upload :
Current File : //opt/oracle/product/18c/dbhomeXE/ord/im/admin/ime121.sql

Rem
Rem $Header: ordim/admin/ime121.sql /main/18 2017/06/11 18:01:53 smavris Exp $
Rem
Rem ime121.sql
Rem
Rem Copyright (c) 2013, 2017, Oracle and/or its affiliates. 
Rem All rights reserved.
Rem
Rem    NAME
Rem      ime121.sql - Downgrade to 12.1
Rem
Rem    DESCRIPTION
Rem      Internal downgrade script for Oracle Multimedia to 12.1
Rem
Rem    NOTES
Rem      Run as sysdba with alter session set current_schema to ORDSYS
Rem
Rem      This script deletes all objects and types that have been added 
Rem       between 12.2 and 12.1.  After this script is run, the imrelod.sql
Rem       script is run to reload 12.1 Oracle Multimedia in the downgraded 
Rem       database.
Rem
Rem
Rem      The first downgrade script must check that Oracle Multimedia
Rem       schemas exist and that dependencies exist and are valid.  The
Rem       first downgrade script must also drop all Oracle Multimedia java 
Rem       classes to ensure new java classes are not left invalid in the
Rem       downgraded database (unless we're downgrading further and earlier
Rem       downgrade scripts need to execute java classes). These steps
Rem       will be moved to the new imdwgrd.sql script when the 12.2 release
Rem       label is created.
Rem
Rem    BEGIN SQL_FILE_METADATA 
Rem    SQL_SOURCE_FILE: ordim/admin/ime121.sql 
Rem    SQL_SHIPPED_FILE: ord/im/admin/ime121.sql
Rem    SQL_PHASE: CATDWGRD
Rem    SQL_STARTUP_MODE: DOWNGRADE 
Rem    SQL_IGNORABLE_ERRORS: NONE 
Rem    SQL_CALLING_FILE: ordim/admin/imdwgrd.sql
Rem    END SQL_FILE_METADATA
Rem
Rem    MODIFIED   (MM/DD/YY)
Rem    smavris     06/07/17 - Correct downgrading, downgraded calls
Rem    smavris     12/13/16 - Remove locator invocation - bug 25114828
Rem    smavris     11/16/16 - Remove checks that belong in top level script -
Rem                           bug 25035523
Rem    smavris     09/19/16 - Rather than delete and reregister schemas, use
Rem                           convert_to_local
Rem    smavris     09/09/16 - Delete and reregistger schemas on downgrade
Rem    smavris     08/24/16 - Add 12.2 downgrade
Rem    alexguti    05/11/16 - Drop ordsys.cartridge
Rem    smavris     04/10/16 - Remove SYS import callout on
Rem                           downgrade and ORDSYS version on upgrade
Rem    smavris     03/07/16 - Add comment
Rem    alexguti    02/23/16 - Drop packages of the new PL/SQL relational 
Rem			      interface and drop synonyms.
Rem    smavris     12/06/15 - Remove sys.immisc to sys, Remove OrdErrorInt
Rem    smavris     11/30/15 - Restore inherit priv
Rem    smavris     07/20/15 - Handle long ident downgrade
Rem    smavris     01/14/15 - Schema qualify dbms_registry
Rem    smavris     08/07/13 - Remove sets, increate script_name varchar lengths
Rem    smavris     07/30/13 - Downgrade script for 12.1
Rem    smavris     07/30/13 - Created
Rem

@@?/rdbms/admin/sqlsessstart.sql

Rem
Rem Downgrade from subsequent releases
Rem 
@@ime122.sql

alter session set current_schema="SYS";
execute sys.dbms_registry.downgrading('ORDIM');

Rem
Rem Restore inherit privs
Rem
grant inherit privileges on user SYS to ORDSYS;
grant inherit privileges on user SYS to ORDPLUGINS;

Rem
Rem Drop sys version of move tablespace package (restore to ordsys)
Rem
drop package sys.ord_admin;

Rem
Rem Drop sys version of import callout (restore to ordsys)
Rem
drop package sys.ordimdpcallouts;

--
-- If we are downgrading a PDB, convert all xml schema related objects to
-- local (as they were in 12.1.0.2).
--

DECLARE
   con_id    VARCHAR2(100);
   con_name  VARCHAR2(128);
   stmt      VARCHAR2(1000);
   obj_name  VARCHAR2(128);
   namespace NUMBER;
   type      cursor_type is ref cursor;
   query_crs cursor_type;

BEGIN

  con_id := sys_context('USERENV', 'CON_ID');
  con_name := sys_context('USERENV', 'CON_NAME');
  if (con_id <> 0) AND (con_name <> 'CDB$ROOT') then
    stmt := ' select o.name, o.namespace from SYS.OBJ$ o, ' ||
            '   sys.user$ u ' ||
            ' where u.name = ''ORDSYS'' and u.user# = o.owner# ' ||
            ' and (o.name like ''%_ORD_DCM_T'' or ' ||
            '      o.name like ''%_ORD_DCM_C'' or ' ||
            '      o.name like ''%_ORD_IMG_T'' or ' ||
            '      o.name like ''%_ORD_IMG_C'') ';

    open query_crs for stmt;
    loop
      fetch query_crs into obj_name, namespace;
      exit when query_crs%NOTFOUND ;

      begin
        sys.dbms_pdb.convert_to_local('ORDSYS', obj_name, namespace);
      
      exception when others then
        null;
      end;
    end loop;
    close query_crs;
  end if;
END;
/

alter session set current_schema="ORDSYS";

Rem
Rem Remove internal error handling package
Rem
drop package ordsys.ORDErrorInt;

Rem
Rem Drop synonyms of the new PL/SQL relational interface packages
Rem
drop public synonym ord_audio;
drop public synonym ord_image;
drop public synonym ord_video;
drop public synonym ord_doc;

Rem
Rem Remove packages of the new PL/SQL relational interface
Rem
drop package ordsys.ord_audio;
drop package ordsys.ord_image;
drop package ordsys.ord_video;
drop package ordsys.ord_doc;

Rem
Rem Drop ordsys.cartridge so reload script will restore 
Rem original authid current_user
Rem

drop package ordsys.cartridge;

--
-- Restore columns that we increased due to long identifier changes.  No need
-- to trim data values before downgrade since longer data values can only be
-- populated when COMPAT is set to 12.2 which would disallow a downgrade.
--
--   First restore USERNAME field in ORDSYS.ORD_USAGE_RECS
--
begin
  execute immediate 
  'alter table ordsys.ord_usage_recs modify (username varchar2(30))';
end;
/

--
-- Now Alter ORDDATA.ORDDCM_CT_VLD_MSG to restore size of USER_NAME field
--
alter session set current_schema="ORDDATA";
begin
  execute immediate
  'alter table orddata.orddcm_ct_vld_msg modify (user_name varchar2(64))';
end;
/


REM 
REM Drop all Oracle Multimedia java classes only if we're not downgrading to
REM 11.2 or earlier.  We need java classes to drop DICOM data model docs in
REM 11.2
REM
alter session set current_schema="SYS";
COLUMN :script_name NEW_VALUE comp_file NOPRINT
Variable script_name varchar2(256)

Declare
  p_version SYS.registry$.prv_version%type;
Begin
  p_version := substr(sys.dbms_registry.prev_version('ORDIM'),1,6);

  if p_version <= '11.2.0' then
    :script_name := sys.dbms_registry.nothing_script;
  else
    :script_name := '@imclnjav.sql';
  end if;

  exception 
    when others then 
      :script_name := sys.dbms_registry.nothing_script;
end;
/

alter session set current_schema="ORDSYS";
select :script_name from dual;
@&comp_file

-- The following should be at the end of the ORDIM part of the file
-- executed as ORDSYS
EXECUTE sys.dbms_registry.downgraded('ORDIM', '12.1.0');

alter session set current_schema="SYS";

@?/rdbms/admin/sqlsessend.sql

OHA YOOOO