MINI MINI MANI MO

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

Rem
Rem $Header: sdo/admin/pg/opgutlh.sql /main/6 2017/09/29 09:00:17 alwu Exp $
Rem
Rem opgutlh.sql
Rem
Rem Copyright (c) 2013, 2017, Oracle and/or its affiliates. 
Rem All rights reserved.
Rem
Rem    NAME
Rem      opgutlh.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    MODIFIED   (MM/DD/YY)
Rem    alwu        09/28/17 - shorten several API names
Rem    alwu        03/23/17 - XbranchMerge alwu_bug-24319503 from
Rem                           st_sdo_12.2.0.1.0
Rem    alwu        08/02/16 - fix bug 24312220
Rem    alwu        12/03/15 - add SQL FILE metadata
Rem    alwu        11/20/15 - add get_storage_clause API
Rem    alwu        07/23/15 - fix bug 21226251
Rem    alwu        01/21/14 - add mdsys to package names
Rem    alwu        01/13/14 - add API for generate_graph_tmp_work_tab
Rem    alwu        12/19/13 - factor out LOG=5 setting
Rem    alwu        11/25/13 - add get_scn
Rem    alwu        11/18/13 - add safe rowcount API
Rem    alwu        11/18/13 - add utility function
Rem    alwu        11/18/13 - start
Rem    alwu        11/18/13 - Created
Rem
Rem    BEGIN SQL_FILE_METADATA 
Rem    SQL_SOURCE_FILE: sdo/admin/pg/opgutlh.sql 
Rem    SQL_SHIPPED_FILE: md/admin/opgutlh.sql 
Rem    SQL_PHASE: OPGUTLH
Rem    SQL_STARTUP_MODE: NORMAL 
Rem    SQL_IGNORABLE_ERRORS: NONE 
Rem    SQL_CALLING_FILE: sdo/admin/pg/opgrelod.sql
Rem    END SQL_FILE_METADATA

SET ECHO ON
SET FEEDBACK 1
SET NUMWIDTH 10
SET LINESIZE 80
SET TRIMSPOOL ON
SET TAB OFF
SET PAGESIZE 100

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

create or replace package mdsys.opg_utl as

  function get_scn return number;


   GET_STATS constant varchar2(1000) := '
    select name, value from (
      select ''stat.. '' || n.name name, t.value  value
        from v$mystat   t join v$statname n on t.statistic# = n.statistic#
       where n.name in (''redo size'', ''db block gets'', ''consistent gets'',
                        ''physical reads'',''sorts (memory)'',''sorts (disk)'',
                        ''recursive calls'',''redo write time'',
                        ''physical writes'',''rows processed'',
                        ''bytes sent via SQL*Net to client'',
                        ''bytes received via SQL*Net from client'',
                        ''SQL*Net roundtrips to/from client'')
          or (n.name like ''%ga %'')
          or (n.name like ''%direct temp%'')
    union all
      select ''latch. '' || n.name name, n.gets  value
        from v$latch n
       where n.name in (''library cache pin'', ''library cache pin allocation'',
                        ''library cache'', ''shared pool'')
     )  
     order by name
  ';


  -- v$sesstat does not help much
  GET_STATS_NEW constant varchar2(1000) := '
    select name, value from (
      select ''stat.. '' || n.name name, t.value  value
        from v$sesstat   t join v$statname n on t.statistic# = n.statistic#
       where t.sid = sys_context(''userenv'',''sid'')  and
          (n.name in (''redo size'', ''db block gets'', ''consistent gets'',
                        ''physical reads'',''sorts (memory)'',''sorts (disk)'',
                        ''recursive calls'',''redo write time'',
                        ''physical writes'',''rows processed'',
                        ''bytes sent via SQL*Net to client'',
                        ''bytes received via SQL*Net from client'',
                        ''SQL*Net roundtrips to/from client'')
          or (n.name like ''%ga %'')
          or (n.name like ''%direct temp%''))
    union all
      select ''latch. '' || n.name name, n.gets  value
        from v$latch n
       where n.name in (''library cache pin'', ''library cache pin allocation'',
                        ''library cache'', ''shared pool'')
     )  
     order by name
  ';


  procedure exe_plan_prepare;

  procedure exe_plan_dump;

  function get_elapsed_time_in_sec(nStart number) return varchar2;

  function bool_to_str(b in boolean) return varchar2;

  /**
   * Get the value of the iPos'th number out from
   * the given string that is delimited by a single space ' '
   *
   * @param iPos MUST be a positive integer.
   */
  function get_number_in_pos(vcVal in varchar2,
                             iPos  in int ) return number;


  function get_columnar_compress_syn return varchar2;


  function get_parameter(vcOptions in varchar2,
                            vcMark in varchar2,
                             vcEnd in varchar2 default null) return varchar2;


  function get_string_parameter(vcOptions in varchar2,
                                   vcMark in varchar2,
                                    vcEnd in varchar2 default null) return varchar2;


  function get_int_parameter(vcOptions in varchar2,
                                vcMark in varchar2) return int;



  /**
   * If returns NULL, it means that MDSYS has no privilege to read
   */
  function get_session_parallel_query_dop return number;


  /**
   * If returns NULL, it means that MDSYS has no privilege to read
   */
  function get_session_parallel_dml_dop return number;


    -- This function is added because we have observed negative rowcounts returned during inference.
  -- We noticed that in cases when more than 2^31 rows are returned, 
  -- sql%rowcount overflows and we need to add 2^32 to the end result to get the right count. 
  -- See bug 8585355 for details.
  -- Vlad, 6/9/2009
  function get_safe_rowcount(cnt int) return int;
    

  /**
   * This procedure configures the trace setting 
   */
  procedure process_trace_setting(options varchar2);


  /**  
   * This function returns a unique name 
   * that can be used to create an intermediate 
   * working table
   * Note that session ID will be used as part of the
   * table name.
   * Also, marker will be included in the name to differentiate
   * different categories of tables.
   */
  function generate_graph_tmp_work_tab(
   graph  in varchar2,
   marker in varchar2 default '$TW'
   )
  return varchar2;


  /**  
   * This function returns a unique name 
   * that can be used to create an intermediate 
   * working table
   * Note that session ID will be used as part of the
   * table name.
   * Also, marker will be included in the name to differentiate
   * different categories of tables.
   */
  function generate_graph_tmp_work_tab(
   graph  in varchar2,
   sid    in integer,
   marker in varchar2 default '$TW'
   )
  return varchar2;

  /**
   * This function returns " compress nologging " when
   * options is null and tbs is null.
   * When there are tablespace setting, a "tablespace ..." clause
   * will be added.
   * 
   * This function is to be used when create a table.
   */
  function get_compress_nolog_tbs(
    tbs in varchar2, options in varchar2) return varchar2;


  /**
   * This function returns " compress nologging " when
   * options is null and tbs is null.
   * When there are tablespace setting, a "tablespace ..." clause
   * will be added.
   * 
   * This function is to be used when create a table.
   */
  function get_compress_nolog_tbs_set(
    tbs in varchar2, options in varchar2) return varchar2;
  
  /**
   * This function returns either an empty string or something
   * like "tablespace ...." clause 
   * 
   * This function is to be used when create an index.
   */
  function get_tbs_clause(
    tbs in varchar2) return varchar2;


  /**
   * This function returns storage clause to be used in CREATE TABLE or INDEX
   */
  function get_storage_clause return varchar2;
end;
/

show errors;

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

OHA YOOOO