MINI MINI MANI MO
Rem
Rem $Header: sdo/admin/semdbmigi.sql /main/8 2017/05/03 12:18:33 rjanders Exp $
Rem
Rem semdbmigi.sql
Rem
Rem Copyright (c) 2012, 2017, Oracle and/or its affiliates.
Rem All rights reserved.
Rem
Rem NAME
Rem semdbmigi.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/semdbmigi.sql
Rem SQL_SHIPPED_FILE: md/admin/semdbmigi.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 rjanders 04/27/17 - Correct "SQL_PHASE" metadata values
Rem rjanders 03/10/17 - Add missing SQL_FILE_METADATA information
Rem sravada 01/11/17 - bug 25370681
Rem matperry 12/22/15 - use sparql_max aggregate to check for 12.1
Rem install
Rem matperry 12/04/15 - refactor for 12.2 - catsem is run separately
Rem matperry 05/12/14 - add 12.2 upgrade
Rem rjanders 03/15/13 - #16473696: Start/End _ORACLE_SCRIPT
Rem initialization
Rem matperry 07/06/12 - Created
Rem
Rem ********************************************************************
Rem #16473696: Indicate Oracle-Supplied object
@@?/rdbms/admin/sqlsessstart.sql
Rem ********************************************************************
--------------------------------------------------------------------------
-- semdbmig internal: called by SDO scripts. Does not alter session --
-- to set current_schema to SYS when exiting, which avoids potentially --
-- messing up subsequent SDO scripts. --
--------------------------------------------------------------------------
COLUMN :script_1 NEW_VALUE comp_file1 NOPRINT
VARIABLE script_1 VARCHAR2(50)
-- get the appropriate scripts for the upgrade --
declare
type_102_exists NUMBER;
type_11_exists NUMBER;
type_112_exists NUMBER;
type_121_exists NUMBER;
network_exists NUMBER;
begin
-- determine if the semantic component has been installed and if so which version --
-- see if 10.2 SDO_RDF_TRIPLE_S type is present in DB
SELECT count(*) INTO type_102_exists FROM ALL_TYPE_ATTRS
WHERE type_name='SDO_RDF_TRIPLE_S' AND attr_name='RDF_T_ID'
AND owner='MDSYS';
-- see if 11 SDO_RDF_TRIPLE_S type is present in DB
SELECT count(*) INTO type_11_exists FROM ALL_TYPE_ATTRS
WHERE type_name='SDO_RDF_TRIPLE_S' AND attr_name='RDF_C_ID'
AND owner='MDSYS';
-- see if 11.2 RDF_PARAMETER table exists
SELECT count(*) INTO type_112_exists
FROM SYS.ALL_OBJECTS
WHERE object_name='RDF_PARAMETER' AND owner='MDSYS';
-- see if 12.1 SPARQL aggregate exists
SELECT count(*) INTO type_121_exists
FROM SYS.ALL_OBJECTS
WHERE object_name='SPARQL_MAX' AND owner='MDSYS'
AND object_type='TYPE';
-- see if a semantic network exists --
select count(*) into network_exists
from SYS.all_objects
where object_name = 'RDF_VALUE$' and owner = 'MDSYS';
-- if semantic component has not been installed then do nothing --
if (type_102_exists = 0 and type_11_exists = 0) then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'Not upgrading Semantic Technologies: it is not installed');
:script_1 := dbms_registry.nothing_script;
-- if 10.2 is installed --
elsif (type_102_exists > 0) then
-- if there is no network then uninstall --
if (network_exists = 0) then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'Uninstalling Semantic Technologies Release 10.2. No semantic network present.');
:script_1 := '@semremov.sql';
else
-- if there is a network then make rdf_match unusable --
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'ERROR: Not upgrading to Oracle Semantic Technologies Release 11.2. ' ||
'A semantic network from Release 10.2 exists and requires data migration. ' ||
'Please run the catsem10i.sql script to perform data migration and complete the ' ||
'upgrade to Release 11.2.');
execute immediate
'CREATE OR REPLACE FUNCTION MDSYS.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 from Release 10.2 exists. '' ||
''Please run the catsem10i.sql script to perform data migration and complete the '' ||
''upgrade to Release 11.2.'');
END;';
:script_1 := dbms_registry.nothing_script;
end if;
-- if 12.1 or later is installed then upgrade from 12.1 --
elsif (type_121_exists > 0) then
-- no network, so uninstall and then re-install
if (network_exists = 0) then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'Upgrading Semantic Technologies from Release 12.1 to 12.2: uninstall-install');
-- uninstall --
:script_1 := '@semremov.sql';
else
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'Upgrading Semantic Technologies from Release 12.1 to 12.2: upgrade');
-- migrate to 12.2 --
:script_1 := '@semu121.sql';
end if;
-- if 11.2 is installed then upgrade from 11.2 --
elsif (type_112_exists > 0) then
-- no network, so uninstall and then re-install
if (network_exists = 0) then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'Upgrading Semantic Technologies from Release 11.2 to 12.1: uninstall-install');
-- uninstall --
:script_1 := '@semremov.sql';
else
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'Upgrading Semantic Technologies from Release 11.2 to 12.1: upgrade');
-- stacked migration --
:script_1 := '@semu112.sql';
end if;
-- if 11.1 is installed then upgrade from 11.1 --
elsif (type_11_exists > 0) then
-- no network, so uninstall and then re-install
if (network_exists = 0) then
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'Upgrading Semantic Technologies from Release 11.1 to 12.1: uninstall-install');
-- uninstall --
:script_1 := '@semremov.sql';
else
SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
'Upgrading Semantic Technologies from Release 11.1 to 12.1: upgrade');
-- stacked migration --
:script_1 := '@semu111.sql';
end if;
end if;
end;
/
-- run the appropriate scripts
alter session set current_schema=MDSYS;
SELECT :script_1 FROM SYS.DUAL;
@&comp_file1
-- make sure we exit as MDSYS
alter session set current_schema=MDSYS;
Rem ********************************************************************
Rem #16473696: Indicate Oracle-Supplied object
@?/rdbms/admin/sqlsessend.sql
Rem ********************************************************************
OHA YOOOO