MINI MINI MANI MO

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

Rem
Rem $Header: sdo/admin/sdotnpc.sql /main/20 2017/11/05 17:25:28 rjanders Exp $
Rem
Rem sdotnpc.sql
Rem
Rem Copyright (c) 2006, 2017, Oracle and/or its affiliates. 
Rem All rights reserved.
Rem
Rem    NAME
Rem      sdotnpc.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/sdotnpc.sql
Rem    SQL_SHIPPED_FILE: md/admin/sdotnpc.sql
Rem    SQL_PHASE: SDOTNPC
Rem    SQL_STARTUP_MODE: NORMAL
Rem    SQL_IGNORABLE_ERRORS: NONE
Rem    SQL_CALLING_FILE: sdo/admin/catmdsdop2.sql
Rem    END SQL_FILE_METADATA
Rem
Rem    MODIFIED   (MM/DD/YY)
Rem    rjanders    10/31/17 - Correct ORA-01442: column to be modified to
Rem                           NOT NULL is already NOT NULL
Rem    rjanders    06/30/17 - Add SYS/MDSYS prefixes
Rem    rjanders    05/10/17 - #26037683: Raise 'when other' exceptions
Rem    rjanders    03/23/17 - #25437999: Remove 'when others then NULL'
Rem                           handlers
Rem    rjanders    03/09/17 - Add missing SQL_FILE_METADATA information
Rem    sravada     01/11/17 - bug 25370681
Rem    rjanders    09/16/15 - #21825604: Remove WITH GRANT OPTION from PUBLIC
Rem    sravada     06/29/15 - change CURRENT_SCHEMA to CURRENT_USER
Rem    rjanders    02/01/15 - #20418139: Cannot grant SELECT to PUBLIC
Rem    rjanders    01/16/15 - long identifier project phase 1
Rem    rjanders    09/16/13 - OCCS: Remove hardtabs
Rem    rjanders    03/15/13 - #16473696: Start/End _ORACLE_SCRIPT
Rem                           initialization
Rem    sravada     02/14/08 - upgrade diffs
Rem    rkothuri    05/23/06 - add tin read and clip functions 
Rem    rkothuri    05/03/06 - add synonym 
Rem    rkothuri    01/31/06 - TIN functionality 
Rem    rkothuri    01/31/06 - TIN functionality 
Rem    rkothuri    01/31/06 - Created
Rem

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

declare
  already_exists exception;
  pragma exception_init(already_exists, -00955);
begin
   begin
   execute immediate
  ' CREATE  TYPE SDO_ORGSCL_TYPE
    TIMESTAMP ''2006-02-16:11:08:14''
    OID ''0CEDBB8FA104A787E040578CB3050404''
    AS OBJECT (
       extent           SDO_MBR,        
       scale            SDO_VPOINT_TYPE, 
       ord_cmp_type     SDO_VPOINT_TYPE)'; 
   exception
     when already_exists then NULL;
     when others then
       SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                              'EXCEPTION[sdotnpc.sql(' || $$PLSQL_LINE || ')1]: ' || SQLERRM); RAISE;
 end;
end;
/
show errors;

grant execute on sdo_orgscl_type to public;
create or replace  public synonym sdo_orgscl_type for mdsys.sdo_orgscl_type;


-- block table same for pc
declare
  already_exists exception;
  pragma exception_init(already_exists, -00955);
begin
  begin
   execute immediate
   ' CREATE  TYPE SDO_PC_BLK 
    TIMESTAMP ''2006-02-16:10:48:17''
    OID ''0CEDBB8FA101A787E040578CB3050404''
    AS OBJECT (
       obj_id           NUMBER ,
       blk_id           NUMBER,
       blk_extent       sdo_geometry,
       blk_domain       sdo_orgscl_type,
       pcblk_min_res    NUMBER,
       pcblk_max_res    NUMBER,
       num_points       NUMBER,
       num_unsorted_points NUMBER,
       pt_sort_dim      NUMBER,
       points           BLOB)';
   exception
     when already_exists then NULL;
     when others then
       SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                              'EXCEPTION[sdotnpc.sql(' || $$PLSQL_LINE || ')2]: ' || SQLERRM); RAISE;
 end;
end;
/
show errors;

grant execute on mdsys.sdo_pc_blk to public;


declare
  already_exists exception;
  pragma exception_init(already_exists, -00955);
begin
  begin
    execute immediate 
  'CREATE TABLE SDO_PC_BLK_TABLE of mdsys.SDO_PC_BLK';
   exception
     when already_exists then NULL;
     when others then
       SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                              'EXCEPTION[sdotnpc.sql(' || $$PLSQL_LINE || ')3]: ' || SQLERRM); RAISE;
  end;
end;
/
SHOW ERRORS

grant read on mdsys.sdo_pc_blk_table to public;

create or replace public synonym sdo_pc_blk for mdsys.sdo_pc_blk;

declare
  already_exists exception;
  pragma exception_init(already_exists, -00955);
begin
  begin 
   execute immediate
   'CREATE TYPE SDO_PC_BLK_TYPE
    TIMESTAMP ''2006-08-06:16:01:15''
    OID ''1A6256B2DC759CAFE040578CB3053028''
    AS TABLE of MDSYS.SDO_PC_BLK'; 
   exception
     when already_exists then NULL;
     when others then
       SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                              'EXCEPTION[sdotnpc.sql(' || $$PLSQL_LINE || ')4]: ' || SQLERRM); RAISE;
 end;
end;
/
show errors;

grant execute on mdsys.sdo_pc_blk_type to public;

-- NOTE: DO NOT change this type definition - for backward compatibility,
-- ALL future table modifications MUST be done using ALTER TABLE operations.

-- "70" is 2x32 + '.' + 4x'"'
declare
begin
   begin
   execute immediate
   ' CREATE OR REPLACE TYPE SDO_PC  
    TIMESTAMP ''2006-02-16:10:51:03''
    OID ''0CEDBB8FA102A787E040578CB3050404''
    AS OBJECT (
       base_table           VARCHAR2(70),
       base_table_col       VARCHAR2(1024),
       pc_id                NUMBER,
       blk_table            VARCHAR2(70),  
       ptn_params           VARCHAR2(1024),
       pc_extent            sdo_geometry,
       pc_tol               NUMBER,     
       pc_tot_dimensions    NUMBER,
       pc_domain            sdo_orgscl_type, 
       pc_val_attr_tables   SDO_STRING_ARRAY,
       pc_other_attrs       SYS.XMLTYPE)';
   exception
     when others then
       SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
         'CREATE TYPE SDO_PC ERROR=' || SQLERRM);
 end;
end;
/
show errors;

-- 12.2: Increase SDO_OWNER, SDO_TABLE_NAME column size from 70 to 270

-- It will still keep the same OID, etc. but the type version will change.

-- "270" is 2x130 + '.' + 4x'"'
declare
begin
  execute immediate
 ' alter type SDO_PC
   modify attribute ( base_table VARCHAR2(270),
                      blk_table VARCHAR2(270) ) cascade including table data';
  exception
    when others then
      SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
        'MODIFY TYPE SDO_PC ERROR=' || SQLERRM);
end;
/
SHOW ERRORS

grant execute on sdo_pc to public;
create or replace public synonym sdo_pc for mdsys.sdo_pc;


-- block table for tins 
declare
begin
  begin
   execute immediate
   ' CREATE OR REPLACE TYPE SDO_TIN_BLK
    TIMESTAMP ''2006-05-31:09:18:22''
    OID ''1517E67D6019D5FAE040578CB30565D0''
    AS OBJECT (
       obj_id           NUMBER ,
       blk_id           NUMBER,
       blk_extent       sdo_geometry,
       blk_domain       sdo_orgscl_type,
       pcblk_min_res    NUMBER,
       pcblk_max_res    NUMBER,
       num_points       NUMBER,
       num_unsorted_points NUMBER,
       pt_sort_dim      NUMBER,
       points           BLOB,
       tr_lvl           NUMBER,
       tr_res           NUMBER,
       num_triangles    NUMBER,
       tr_sort_dim      NUMBER,
       triangles        BLOB)';
   exception
     when others then
       SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
         'CREATE TYPE SDO_TIN ERROR=' || SQLERRM);
 end;
end;
/
show errors;

grant execute on mdsys.sdo_tin_blk to public;

declare
  already_exists exception;
  pragma exception_init(already_exists, -00955);
begin
  begin
    execute immediate 
      'CREATE TABLE SDO_TIN_BLK_TABLE of mdsys.SDO_TIN_BLK';
    exception
      when already_exists then NULL;
      when others then
        SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                               'EXCEPTION[sdotnpc.sql(' || $$PLSQL_LINE || ')5]: ' || SQLERRM); RAISE;
  end;
end;
/
show errors;

grant read on mdsys.sdo_tin_blk_table to public;

create or replace  public synonym sdo_tin_blk for mdsys.sdo_tin_blk;


declare
  already_exists exception;
  pragma exception_init(already_exists, -00955);
begin
  begin
   execute immediate
   'CREATE TYPE SDO_TIN_BLK_TYPE
    TIMESTAMP ''2006-08-06:16:05:19''
    OID ''1A6256B2DC769CAFE040578CB3053028''
    AS TABLE of MDSYS.SDO_TIN_BLK';
   exception
     when already_exists then NULL;
     when others then
       SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                              'EXCEPTION[sdotnpc.sql(' || $$PLSQL_LINE || ')6]: ' || SQLERRM); RAISE;
 end;
end;
/
show errors;

grant execute on mdsys.sdo_tin_blk_type to public;



-- NOTE: DO NOT change this type definition - for backward compatibility,
-- ALL future table modifications MUST be done using ALTER TYPE operations.

-- "70" is 2x32 + '.' + 4x'"'
declare
  already_exists exception;
  pragma exception_init(already_exists, -00955);
begin
   begin
   execute immediate
   ' CREATE  TYPE SDO_TIN
    TIMESTAMP ''2006-02-16:10:52:24''
    OID ''0CEDBB8FA103A787E040578CB3050404''
    AS OBJECT (
       base_table            VARCHAR2(70),
       base_table_col        VARCHAR2(1024),
       tin_id                NUMBER,
       blk_table             VARCHAR2(70),
       ptn_params            VARCHAR2(1024),
       tin_extent            sdo_geometry,
       tin_tol               NUMBER,
       tin_tot_dimensions    NUMBER,
       tin_domain            sdo_orgscl_type,
       tin_break_lines       SDO_GEOMETRY,
       tin_stop_lines        SDO_GEOMETRY,
       tin_void_rgns         SDO_GEOMETRY,
       tin_val_attr_tables   SDO_STRING_ARRAY,
       tin_other_attrs       SYS.XMLTYPE)';
   exception
     when already_exists then NULL;
     when others then
       SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                              'EXCEPTION[sdotnpc.sql(' || $$PLSQL_LINE || ')7]: ' || SQLERRM); RAISE;
 end;
end;
/
show errors;

-- 12.2: Increase SDO_OWNER, SDO_TABLE_NAME column size from 70 to 270

-- It will still keep the same OID, etc. but the type version will change.

-- "270" is 2x130 + '.' + 4x'"'
declare
begin
  execute immediate
 ' alter type SDO_TIN
   modify attribute ( base_table VARCHAR2(270),
                      blk_table VARCHAR2(270) ) cascade including table data';
  exception
    when others then
      SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
        'MODIFY TYPE SDO_TIN ERROR=' || SQLERRM);
end;
/
SHOW ERRORS

grant execute on sdo_tin to public;
create or replace  public synonym sdo_tin for mdsys.sdo_tin;

-- NOTE: DO NOT change this table definition - for backward compatibility,
-- ALL future table modifications MUST be done using ALTER TABLE operations.

declare
  already_exists exception;
  pragma exception_init(already_exists, -00955);
begin
  begin
  execute immediate
'CREATE TABLE SDO_TIN_PC_SEQ
(
   SDO_OWNER                 VARCHAR2(32) NOT NULL,
   TABLE_NAME                VARCHAR2(32) NOT NULL,
   CUR_OBJ_ID                NUMBER,
   CONSTRAINT sdo_pk_seq_tin_pc
       PRIMARY KEY (SDO_OWNER, TABLE_NAME))';
  exception
    when already_exists then NULL;
    when others then
      SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                             'EXCEPTION[sdotnpc.sql(' || $$PLSQL_LINE || ')8]: ' || SQLERRM); RAISE;
  end;
end;
/
SHOW ERRORS;

GRANT READ ON sdo_tin_pc_seq TO PUBLIC;

-- 12.2: Increase SDO_OWNER, SDO_TABLE_NAME column size from 32 to 130

declare
  already_not_null exception;
  pragma exception_init(already_not_null, -1442);
begin
  execute immediate
 ' alter table SDO_TIN_PC_SEQ
   modify (SDO_OWNER VARCHAR2(130) NOT NULL,
           TABLE_NAME VARCHAR2(130) NOT NULL) ';
  exception
    when already_not_null then NULL;
    when others then
      SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
        'alter table SDO_TIN_PC_SEQ ERROR=' || SQLERRM);
end;
/
SHOW ERRORS

GRANT READ ON sdo_tin_pc_seq TO PUBLIC;

-- Metadata for the tin/pc objects 

-- NOTE: DO NOT change this table definition - for backward compatibility,
-- ALL future table modifications MUST be done using ALTER TABLE operations.

declare
  already_exists exception;
  pragma exception_init(already_exists, -00955);
begin
  begin
  execute immediate
'CREATE TABLE SDO_TIN_PC_SYSDATA_TABLE
 (
   SDO_OWNER                 VARCHAR2(32) NOT NULL,
   TABLE_NAME                VARCHAR2(32) NOT NULL,
   COLUMN_NAME               VARCHAR2(1024) NOT NULL,
   DEP_TABLE_SCHEMA          VARCHAR2(32) NOT NULL,
   DEP_TABLE_NAME            VARCHAR2(32) NOT NULL,
   CONSTRAINT sdo_pk_tin_pc
       PRIMARY KEY (DEP_TABLE_SCHEMA, DEP_TABLE_NAME),
   CONSTRAINT sdo_unq_pcattr_tin_pc
       UNIQUE (SDO_OWNER, TABLE_NAME, COLUMN_NAME, 
               DEP_TABLE_SCHEMA, DEP_TABLE_NAME))';
  exception
    when already_exists then NULL;
    when others then
      SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                             'EXCEPTION[sdotnpc.sql(' || $$PLSQL_LINE || ')9]: ' || SQLERRM); RAISE;
  end;
end;
/
SHOW ERRORS;

-- 12.2: Increase SDO_OWNER, SDO_TABLE_NAME column size from 32 to 130

declare
  already_not_null exception;
  pragma exception_init(already_not_null, -1442);
begin
  execute immediate
 ' alter table SDO_TIN_PC_SYSDATA_TABLE
   modify (SDO_OWNER VARCHAR2(130) NOT NULL,
           TABLE_NAME VARCHAR2(130) NOT NULL,
           DEP_TABLE_SCHEMA VARCHAR2(130) NOT NULL,
           DEP_TABLE_NAME VARCHAR2(130) NOT NULL) ';
  exception
    when already_not_null then NULL;
    when others then
      SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
        'alter table SDO_TIN_PC_SYSDATA_TABLE ERROR=' || SQLERRM);
end;
/
SHOW ERRORS

GRANT READ ON sdo_tin_pc_sysdata_table TO PUBLIC;

-- ----------------------------------------------------------------
--      Create an index on the metadata table
-- ----------------------------------------------------------------

declare
  index_not_found exception;
  pragma exception_init(index_not_found, -01418);
begin
  execute immediate 'drop index SDO_TIN_PC_IDX';
  exception
    when index_not_found then NULL;
    when others then
      SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
                             'EXCEPTION[sdotnpc.sql(' || $$PLSQL_LINE || ')10]: ' || SQLERRM); RAISE;
end;
/
SHOW ERRORS

declare
begin
  begin
   execute immediate
' CREATE INDEX SDO_TIN_PC_IDX ON SDO_TIN_PC_SYSDATA_TABLE
(SDO_OWNER, TABLE_NAME, COLUMN_NAME) ';
  exception
    when others then
      SYS.DBMS_SYSTEM.KSDWRT(SYS.DBMS_SYSTEM.TRACE_FILE,
        'create index SDO_TIN_PC_SYSDATA_TABLE ERROR=' || SQLERRM);
  end;
end;
/
SHOW ERRORS

-- ----------------------------------------------------------------
--          Create ALL view of SDO_TIN_PC_SYSDATA_TABLE
-- ----------------------------------------------------------------
CREATE OR REPLACE VIEW MDSYS.ALL_SDO_TIN_PC_SYSDATA AS
SELECT SDO_OWNER                 OWNER,
       TABLE_NAME,
       COLUMN_NAME, 
       DEP_TABLE_SCHEMA,
       DEP_TABLE_NAME
FROM MDSYS.SDO_TIN_PC_SYSDATA_TABLE a
WHERE
(
    exists
    (
     select table_name from sys.all_tables
     where table_name=a.table_name
     and owner = sdo_owner
     union all
     select table_name from sys.all_object_tables
     where table_name=a.table_name
     and owner = sdo_owner
     union all
     select view_name table_name from sys.all_views
     where  view_name=a.table_name
     and owner = sdo_owner
     )
);

GRANT READ ON mdsys.all_sdo_tin_pc_sysdata TO PUBLIC;
CREATE OR REPLACE PUBLIC SYNONYM all_sdo_tin_pc_sysdata FOR
  mdsys.all_sdo_tin_pc_sysdata;


-- ----------------------------------------------------------------
--      Create USER view of SDO_TIN_PC_SYSDATA_TABLE
-- ----------------------------------------------------------------
CREATE OR REPLACE VIEW mdsys.user_sdo_tin_pc_sysdata AS
SELECT *  FROM mdsys.all_sdo_tin_pc_sysdata
WHERE owner = sys_context('userenv', 'CURRENT_USER');

GRANT READ ON mdsys.user_sdo_tin_pc_sysdata TO PUBLIC;
CREATE OR REPLACE PUBLIC SYNONYM user_sdo_tin_pc_sysdata FOR
  mdsys.user_sdo_tin_pc_sysdata;




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


OHA YOOOO