Rem
Rem $Header: emcore/source/oracle/sysman/emdrep/sql/core/11.2.0.1/basic/basic_ng_types_met.sql rbali_oneoff_updated/1 2025/03/14 06:41:12 rbali Exp $
Rem
Rem basic_ng_types_met.sql
Rem
Rem Copyright (c) 2010, 2025, Oracle and/or its affiliates. 
Rem All rights reserved.

Rem BEGIN EMRU_FILE_METADATA
Rem EMRU_SOURCE_FILE:emcore/source/oracle/sysman/emdrep/sql/core/11.2.0.1/basic/basic_ng_types_met.sql
Rem EMRU_UNIX_DELIVERABLES:
Rem emcore/source/oracle/sysman/emdrep/sql/core/11.2.0.1/basic/basic_ng_types_met.sql

Rem EMRU_FILE_POSTINSTALL:<!!! enter the view based location of the executable file. If there is NONE leave as-is !!!>
Rem EMRU_GENERIC_FLAG:NONE
Rem END EMRU_FILE_METADATA

Rem
Rem    NAME
Rem      basic_ng_types_met.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    gbafna      01/07/25 - make synonyms noneditionable
Rem    rnadidar    02/11/15 - cut over to EBR
Rem    bwadding    09/12/12 - fix size of string varray type, EM_METRIC_STRING_ARRAY to 1000 from 100.
Rem    bwadding    03/30/11 - add message field to debug record type
Rem    bwadding    02/12/11 - add types for returning errors from bulk metric
Rem                           insert proc
Rem    bwadding    12/02/10 - add support for batch loading of data
Rem    ushaft      03/17/10 - Created
Rem

rem
rem TYPE EM_METRIC_VALUE_ARRAY.
rem This is the data type for storing a list of numeric values.
rem To access a single element of the array in a view or query use the
rem function EM_METRIC_VALUE_ACCESS.
rem
rem The size of the VARRAY is 120 and should not be changed, at least
rem as long as we use IOTs for data tables. Higher values will cause overflow
rem with 8K block size, which will render the design unusable.
rem
rem Note that the function assumes the array is not null.
rem We declare all such arrays NOT NULL in the tables, so as long as
rem we pass a value from one of the base tables, the array must be not null.
rem
rem We create the function here and not in PL/SQL packages because it is used
rem by views, and the packages may use the views. This creates a circular 
rem dependency which we break.
rem

ALTER SESSION SET CURRENT_SCHEMA=SYSMAN_TYPES;

CREATE OR REPLACE TYPE EM_METRIC_VALUE_ARRAY IS VARRAY (120) OF NUMBER;
/

grant execute on EM_METRIC_VALUE_ARRAY to sysman;

create or replace noneditionable synonym SYSMAN.EM_METRIC_VALUE_ARRAY for EM_METRIC_VALUE_ARRAY;


ALTER SESSION SET CURRENT_SCHEMA=SYSMAN;

CREATE OR REPLACE FUNCTION EM_METRIC_VALUE_ACCESS
      (p_array IN em_metric_value_array, p_i IN INTEGER)
RETURN NUMBER DETERMINISTIC
IS
BEGIN
  IF p_i > 0 AND p_i <= p_array.last THEN
    RETURN p_array(p_i);
  END IF;
  RETURN NULL;
END;
/



CREATE OR REPLACE TYPE EM_METRIC_KEY_ARRAY IS VARRAY (7) OF VARCHAR2(256);
/

CREATE OR REPLACE TYPE EM_METRIC_STRING_ARRAY IS VARRAY (1000) OF VARCHAR2(4000);
/

CREATE OR REPLACE TYPE EM_METRIC_INTEGER_ARRAY IS VARRAY (1000) OF INTEGER;
/

CREATE OR REPLACE TYPE EM_METRIC_DATE_ARRAY IS VARRAY (1000) OF DATE;
/

CREATE OR REPLACE TYPE EM_METRIC_GUID_ARRAY IS VARRAY (1000) OF RAW(16);
/

CREATE OR REPLACE TYPE EM_METRIC_INTEGER_ARRAY_ARRAY IS VARRAY (1000) OF EM_METRIC_INTEGER_ARRAY;
/

CREATE OR REPLACE TYPE EM_METRIC_VALUE_ARRAY_ARRAY IS VARRAY (1000) OF EM_METRIC_VALUE_ARRAY;
/

CREATE OR REPLACE TYPE EM_METRIC_KEY_ARRAY_ARRAY IS VARRAY (1000) OF EM_METRIC_KEY_ARRAY;
/

CREATE OR REPLACE TYPE EM_METRIC_STRING_ARRAY_ARRAY IS VARRAY (1000) OF EM_METRIC_STRING_ARRAY;
/


--
-- types for returning error information
--

CREATE OR REPLACE TYPE EM_METRIC_ERROR_RECORD AS OBJECT (
    error_index         NUMBER,
    error_number        NUMBER,
    message             varchar2(1000));
/

CREATE OR REPLACE TYPE EM_METRIC_ERROR_ARRAY IS VARRAY (1000) OF EM_METRIC_ERROR_RECORD;
/

-- 
-- The following definition is for returning list of duplicate targets
-- 
CREATE OR REPLACE TYPE DUPTGT_INFO_TYPE IS OBJECT (
   TARGET_GUID      VARCHAR2(32),
   DETECTION_TIME   VARCHAR2(32),
   RESOLVED_TIME    VARCHAR2(32) 
 );
/

CREATE OR REPLACE TYPE DUPTGT_INFO_ARRAY_TYPE IS TABLE OF DUPTGT_INFO_TYPE;
/

