MINI MINI MANI MO

Path : /opt/oracle/product/18c/dbhomeXE/md/admin/
File Upload :
Current File : //opt/oracle/product/18c/dbhomeXE/md/admin/semu112post.sql

Rem
Rem $Header: sdo/admin/semu112post.sql /main/13 2017/05/26 16:34:20 rjanders Exp $
Rem
Rem semu112post.sql
Rem
Rem Copyright (c) 2011, 2017, Oracle and/or its affiliates. 
Rem All rights reserved.
Rem
Rem    NAME
Rem      semu112post.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/semu112post.sql
Rem    SQL_SHIPPED_FILE: md/admin/semu112post.sql
Rem    SQL_PHASE: UPGRADE
Rem    SQL_STARTUP_MODE: NORMAL
Rem    SQL_IGNORABLE_ERRORS: NONE
Rem    SQL_CALLING_FILE: NONE
Rem    END SQL_FILE_METADATA
Rem
Rem    MODIFIED   (MM/DD/YY)
Rem    rjanders    05/10/17 - #26037683: Raise 'when other' exceptions
Rem    rjanders    04/27/17 - Correct "SQL_PHASE" metadata values
Rem    rjanders    03/23/17 - #25437999: Remove 'when others then NULL'
Rem                           handlers
Rem    sravada     01/11/17 - bug 25370681
Rem    matperry    02/24/14 - update sem_version check
Rem    matperry    11/18/13 - update sem_version for 12.1.0.2.0
Rem    rjanders    09/16/13 - OCCS: Remove hardtabs
Rem    rjanders    03/16/13 - #16473696: Start/End _ORACLE_SCRIPT
Rem                           initialization
Rem    matperry    06/21/12 - update for 12.1 upgrade: refactor to
Rem                           move rdfctx operator updates to sdordfctx.sql
Rem    matperry    06/15/11 - do not update rdfctx after upgrade from
Rem                           11.2.0.2.0 P1
Rem    matperry    03/27/12 - change sem_version to 12101_B2
Rem    spsundar    05/13/11 - rename sem_contains_score to sem_contains_count
Rem    matperry    05/04/11 - move view recreations to semrelod b/c they should
Rem                           run on downgrade too
Rem    matperry    04/01/11 - add recreation of stats views and missing
Rem                           partitions
Rem    matperry    03/10/11 - Created
Rem

----------------------------------------------------------------------
-- Called after upgrade                                             --
-- Makes any calls to the new codebase to finish upgrading the      --
-- semantics installation                                           --
----------------------------------------------------------------------

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

alter session set current_schema=MDSYS;

-- check value$ to see if data conversion is needed --
declare
  invalid_data         pls_integer := 0;
  check_failed         pls_integer := 0;
  rdf_parameter_exists pls_integer := 0;
  valid_11202plus      pls_integer := 0;
  convert_error exception;
  pragma exception_init(convert_error, -20000);
  table_not_found exception;
  pragma exception_init(table_not_found, -00942);
begin

  ------- data check not relevant for 11.2.0.2.0+ --------
  -- see what type of install we are dealing with --
  select count(*) into rdf_parameter_exists
  from SYS.all_objects
  where owner = 'MDSYS' and object_name = 'RDF_PARAMETER'; 

  if (rdf_parameter_exists > 0) then
    -- look for a valid 11.2.0.2.0 or later install --
    execute immediate
      'select count(*) 
       from mdsys.rdf_parameter
       where namespace = :1 and attribute = :2 and
             description in (:3,:4) and 
             (value in (''11202'', ''11202_P1'', ''11203'', ''11204'') or 
              value like ''12%'')'
    into valid_11202plus
    using 'MDSYS','SEM_VERSION','UPGRADING_VALID','VALID';

    -- only do literal conversion for pre 11.2.0.2.0 --
    if (valid_11202plus = 0) then
      -- check data --
      begin
        execute immediate
          'begin
             mdsys.sdo_rdf_internal.convert_old_rdf_data(migrate=>false);
           end;';
      exception
        when convert_error then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(
            SYS.DBMS_SYSTEM.TRACE_FILE, 
            'SEM_INSTALL: semu112post: convert_old_rdf_data: '||SQLERRM);
      end;

      -- see if convert_old_rdf_data check failed --
      begin
        execute immediate 
          'select count(*)
           from
           mdsys.rdf_parameter
           where namespace = ''MDSYS'' and
                 attribute = ''DATA_CONVERSION_CHECK'' and
                 value = ''FAILED_UNABLE_TO_LOCK_APPLICATION_TABLES'''
        into check_failed;
      exception
      when table_not_found then NULL;
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(
          SYS.DBMS_SYSTEM.TRACE_FILE, 
          'SEM_INSTALL: semu112post: convert_old_rdf_data check failed: '||SQLERRM);
      end;

      -- see if semantic data is valid --
      begin
        execute immediate 
          'select count(*)
           from
           mdsys.rdf_parameter
           where namespace = ''MDSYS'' and
                 (attribute = ''FLOAT_DOUBLE_DECIMAL'' or attribute = ''NULL_LITERAL'' or
                  attribute = ''XSD_TIME'' or attribute = ''XSD_BOOLEAN'') and
                 value = ''INVALID'''
        into invalid_data;
      exception
        when table_not_found then NULL;
        when others then
          SYS.DBMS_SYSTEM.KSDWRT(
            SYS.DBMS_SYSTEM.TRACE_FILE, 
            'SEM_INSTALL: semu112post: convert_old_rdf_data check results: '||SQLERRM);
      end;

      -- if invalid data exists then set rdf_match to a dummy implementation --
      if (invalid_data > 0 or check_failed > 0) then
        execute immediate 
          'CREATE OR REPLACE FUNCTION RDF_MATCH(query     varchar2,
                                                   models    MDSYS.RDF_Models,
                                                   rulebases MDSYS.RDF_Rulebases,
                                                   aliases   MDSYS.RDF_Aliases,
                                                   filter    varchar2,
                                                   index_status varchar2 default NULL,
                                                   options      varchar2 default NULL
                                                  )
            RETURN SYS.ODCINumberList
            AS
            BEGIN
              raise_application_error(-20000, 
                ''Invalid semantic data exists. Please run sdo_rdf_internal.convert_old_rdf_data '' ||
                ''as sysdba to convert invalid data and enable semantic querying.'');
            END;';

        -- give log message --
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE, 
           'SEM_INSTALL: Oracle Semantic Technologies Release 11.2 is invalid because data migration may be needed. ' ||
           'Please run sdo_rdf_internal.convert_old_rdf_data as sysdba to convert invalid data and then ' ||
           'run the semrelod.sql script to enable semantic querying.');

      end if;

    end if;

  end if;

end;
/
show errors;

alter session set current_schema=SYS;

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


OHA YOOOO