Rem drv: <create type="types"/>
Rem $Header: emcore/source/oracle/sysman/emdrep/sql/core/latest/events/rulefwk/incident_rule_types.sql rbali_oneoff_updated/1 2025/03/14 06:41:14 rbali Exp $
Rem
Rem incident_rule_types.sql
Rem
Rem Copyright (c) 2009, 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/latest/events/rulefwk/incident_rule_types.sql
Rem EMRU_UNIX_DELIVERABLES:
Rem emcore/source/oracle/sysman/emdrep/sql/core/latest/events/rulefwk/incident_rule_types.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      incident_rule_types.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      02/03/25 - 
Rem    gbafna      01/07/25 - make synonyms noneditionable
Rem    rnadidar    02/11/15 - cut over to EBR
Rem    punjain     12/22/09 - Incident rule pl/sql objects
Rem    punjain     12/22/09 - Created
Rem

--  Included the conatents of the following files
-- @@&EM_SQL_ROOT/core/11.2.0.1/events/rulefwk/incident_rule_types.sql
-- @@&EM_SQL_ROOT/core/12.1.0.2/events/rulefwk/incident_rule_types_upgrade.sql
-- @@&EM_SQL_ROOT/core/12.1.0.3/events/rulefwk/incident_rule_types_upgrade.sql

CREATE OR REPLACE TYPE EM_RULE_BROKEN_OBJ AS OBJECT
  (
    RULE_ID       NUMBER,
    BROKEN_REASON VARCHAR2(256),
    KEY           VARCHAR2(256),
    ATTR_VALUE    VARCHAR2(256),
    SEL_OBJ_TYPE  NUMBER(1),
 
    CONSTRUCTOR FUNCTION EM_RULE_BROKEN_OBJ(
      p_broken_reason IN VARCHAR2,
      p_key           IN VARCHAR2,
      p_attr_value    IN VARCHAR2 )
    RETURN SELF AS RESULT 
   );
/
  
CREATE OR REPLACE TYPE EM_RULE_BROKEN_ARRAY AS VARRAY(5000) OF EM_RULE_BROKEN_OBJ;
/

CREATE OR REPLACE TYPE EM_RULE_EXPRESSION_OBJ AS OBJECT
  (
    EXPRESSION_GROUP_ID NUMBER,
    ATTR_TYPE           VARCHAR2(10),
    ATTR_NAME           VARCHAR2(64),
    DATATYPE            VARCHAR2(10),
    OPERATOR_CODE       NUMBER(2),
    ATTR_VALUES 	MGMT_MEDIUM_STRING_ARRAY,
    EVENT_CLASS         VARCHAR2(20),
    EXPRESSION_ID 	NUMBER,
    EXPRESSION_TYPE     NUMBER,
    EXCLUSION_GROUP_ID  NUMBER,
    UI_GROUP_ID         NUMBER,
    CONSTRUCTOR FUNCTION EM_RULE_EXPRESSION_OBJ(
      p_expression_group_id IN NUMBER,
      p_attr_type           IN VARCHAR2,
      p_attr_name           IN VARCHAR2,
      p_datatype            IN VARCHAR2 DEFAULT 'STRING',
      p_operator_code       IN NUMBER,
      p_attr_values         IN MGMT_MEDIUM_STRING_ARRAY,
      p_event_class         IN VARCHAR2 DEFAULT NULL,
      p_expression_type     IN NUMBER DEFAULT 1,
      p_ui_group_id         IN NUMBER DEFAULT 0,
      p_exclusion_group_id  IN NUMBER DEFAULT 0)
    RETURN SELF AS RESULT 
   );
/
  
CREATE OR REPLACE TYPE EM_RULE_EXPRESSION_ARRAY AS VARRAY(100000) OF EM_RULE_EXPRESSION_OBJ;
/


CREATE OR REPLACE TYPE EM_RULE_ACTION_OBJ AS OBJECT
  (
    APPLIED_TO NUMBER(1),
    ATTR_NAME  VARCHAR2(256),
    DATATYPE   VARCHAR2(10),
    ATTR_VALUE VARCHAR2(256),
    PROCESSING_STATUS NUMBER(1),    
    CONSTRUCTOR FUNCTION EM_RULE_ACTION_OBJ( p_applied_to IN NUMBER,
        p_attr_name  IN VARCHAR2,
        p_datatype   IN VARCHAR2 DEFAULT 'STRING',
        p_attr_value IN VARCHAR2,
        p_processing_status IN NUMBER DEFAULT 1 )
RETURN SELF AS RESULT
   );
/

CREATE OR REPLACE TYPE EM_RULE_ACTION_ARRAY AS VARRAY(5000) OF EM_RULE_ACTION_OBJ;
/

  
CREATE OR REPLACE TYPE EM_RULE_BASIC_NOTIF_OBJ AS OBJECT
  (
    RECIPIENT         VARCHAR2(256),
    NOTIFICATION_TYPE NUMBER(1),
    RECIPIENT_CC      NUMBER(1),
    RECIPIENT_TYPE    NUMBER(1),
    
    CONSTRUCTOR FUNCTION EM_RULE_BASIC_NOTIF_OBJ(
      p_recipient         IN VARCHAR2,
      p_notification_type IN NUMBER DEFAULT 1,
      p_recipient_cc      IN NUMBER DEFAULT 1,
      p_recipient_type    IN NUMBER DEFAULT 1 )
      
      RETURN SELF AS RESULT 
   );
/

CREATE OR REPLACE TYPE EM_RULE_BASIC_NOTIF_ARRAY AS VARRAY(5000) OF EM_RULE_BASIC_NOTIF_OBJ;
/

CREATE OR REPLACE TYPE EM_RULE_ADV_NOTIF_OBJ AS OBJECT
  (
    APPLIED_TO NUMBER(1),
    DEVICE_ID  NUMBER(12),
    
    CONSTRUCTOR FUNCTION EM_RULE_ADV_NOTIF_OBJ(
      p_applied_to IN NUMBER,
      p_device_id  IN NUMBER )
    
      RETURN SELF AS RESULT      
   );
/
  
CREATE OR REPLACE TYPE EM_RULE_ADV_NOTIF_ARRAY AS VARRAY(5000) OF EM_RULE_ADV_NOTIF_OBJ;
/


CREATE OR REPLACE TYPE EM_RULE_RL_OBJ AS OBJECT
  (
    rule_id NUMBER,
    rl_expression CLOB,
    is_rule_rl NUMBER(1),
    
    CONSTRUCTOR FUNCTION EM_RULE_RL_OBJ(
      p_rule_id       IN NUMBER,
      p_rl_expression IN CLOB )
    RETURN SELF AS RESULT  
  ) ;
/

CREATE OR REPLACE TYPE EM_RULE_RL_ARRAY AS VARRAY(5000) OF EM_RULE_RL_OBJ ;
/

  
CREATE OR REPLACE TYPE EM_RULE_ERROR_OBJ AS OBJECT
  (
    rule_id  NUMBER,
    err_code VARCHAR2(256),
    err_msg  VARCHAR2(256),
  
  CONSTRUCTOR FUNCTION EM_RULE_ERROR_OBJ(
      p_rule_id  IN NUMBER,
      p_err_code IN VARCHAR2,
      p_err_msg  IN VARCHAR2 )
    RETURN SELF AS RESULT 
   ) ;
/
  
CREATE OR REPLACE TYPE EM_RULE_ERROR_ARRAY AS VARRAY(5000) OF EM_RULE_ERROR_OBJ ;
/



CREATE OR REPLACE TYPE EM_RULE_COND_ACTIONS_OBJ AS OBJECT
  (
    COND_ACTION_ID    NUMBER,
    COND_ACTION_ORDER NUMBER(11),
    ACTION_TYPE       NUMBER(10),
    IS_REPEAT         NUMBER(1),
    REPEAT_FREQ       NUMBER,
    REPEAT_COUNT      NUMBER,
    IS_DURATION       NUMBER(1),
    DURATION          NUMBER,
    DURATION_UNIT     NUMBER,
    CONDITIONS        EM_RULE_EXPRESSION_ARRAY,
    ACTIONS           EM_RULE_ACTION_ARRAY,
    BASIC_NOTIFICATION EM_RULE_BASIC_NOTIF_ARRAY,
    ADV_NOTIFICATION  EM_RULE_ADV_NOTIF_ARRAY,
    
    CONSTRUCTOR FUNCTION EM_RULE_COND_ACTIONS_OBJ(
      p_action_type        IN NUMBER,
      p_is_repeat          IN NUMBER DEFAULT 0,
      p_repeat_freq        IN NUMBER DEFAULT 0,
      p_repeat_count       IN NUMBER DEFAULT 0,
      p_is_duration        IN NUMBER DEFAULT 0,
      p_duration           IN NUMBER DEFAULT 0,
      p_duration_unit      IN NUMBER DEFAULT 1,
      p_conditions         IN EM_RULE_EXPRESSION_ARRAY,
      p_actions            IN EM_RULE_ACTION_ARRAY,
      p_basic_notification IN EM_RULE_BASIC_NOTIF_ARRAY,
      p_adv_notification  IN EM_RULE_ADV_NOTIF_ARRAY )
    RETURN SELF AS RESULT 
  );
/

CREATE OR REPLACE TYPE EM_RULE_COND_ACTIONS_ARRAY AS VARRAY(5000) OF EM_RULE_COND_ACTIONS_OBJ;
/


CREATE OR REPLACE TYPE EM_RULE_SET_HEADER_OBJ AS OBJECT
  (
    RULESET_GUID       RAW(16),
    RULESET_ID         NUMBER,
    RULESET_NAME       VARCHAR2(256),
    RULESET_NAME_NLSID VARCHAR2(256),
    OWNER              VARCHAR2(256),
    CREATED_BY         VARCHAR2(256),
    DESCRIPTION        VARCHAR2(256),
    DESCRIPTION_NLSID  VARCHAR2(256),
    RESOURCE_BUNDLE    VARCHAR2(512),
    RULESET_ORDER      NUMBER(11),
    IS_ENABLED         NUMBER(1),
    IS_VISIBLE         NUMBER(1),
    IS_READONLY        NUMBER(1),
    IS_BROKEN          NUMBER(1),
    BROKEN_REASON      VARCHAR2(256),
    PLUGINID           VARCHAR2(256),
    IS_BUSINESS        NUMBER(1),
    LAST_UPDATED_BY    VARCHAR2(256),
    LAST_UPDATED_DATE  DATE,
    CREATION_DATE       DATE,
    PRIV_MODE NUMBER(1),
    
    CONSTRUCTOR FUNCTION EM_RULE_SET_HEADER_OBJ(
        p_ruleset_name       IN VARCHAR2,
        p_ruleset_name_nlsid IN VARCHAR2 DEFAULT NULL,
        p_owner              IN VARCHAR2,
        p_created_by         IN VARCHAR2,
        p_description        IN VARCHAR2,
        p_description_nlsid  IN VARCHAR2 DEFAULT NULL,
        p_resource_bundle    IN VARCHAR2 DEFAULT NULL,
        p_is_enabled         IN NUMBER DEFAULT 1,
        p_is_visible         IN NUMBER DEFAULT 1,
        p_is_readonly        IN NUMBER DEFAULT 0,
        p_is_broken          IN NUMBER DEFAULT 0,
        p_broken_reason      IN VARCHAR2 DEFAULT NULL,
        p_pluginid           IN VARCHAR2 DEFAULT NULL,
        p_is_business        IN NUMBER DEFAULT 1,
        p_priv_mode          IN NUMBER DEFAULT 0)
RETURN SELF AS RESULT ) ;
/
    
CREATE OR REPLACE TYPE EM_RULE_SET_HEADER_ARRAY AS VARRAY(50) OF EM_RULE_SET_HEADER_OBJ;
/ 
  
  
CREATE OR REPLACE TYPE EM_RULE_SET_DETAILS_OBJ AS OBJECT
  (
    TARGET_SELECTION_TYPE NUMBER(1),
    SOURCE_SELECTION_TYPE VARCHAR2(30),
    RL_EXPRESSION EM_RULE_RL_OBJ,
    RULESET_HEADER EM_RULE_SET_HEADER_OBJ,
    SOURCE_SELECTION EM_RULE_EXPRESSION_ARRAY,
    SELECTED_TARGETS MGMT_MEDIUM_STRING_ARRAY,
    EXCLUDED_TARGETS MGMT_MEDIUM_STRING_ARRAY,
    TARGET_TYPES EM_RULE_EXPRESSION_OBJ,
    
    CONSTRUCTOR FUNCTION EM_RULE_SET_DETAILS_OBJ(
      p_target_selection_type IN NUMBER,
      p_source_selection_type IN VARCHAR2,
      p_rl_expression         IN EM_RULE_RL_OBJ DEFAULT NULL,
      p_ruleset_header        IN EM_RULE_SET_HEADER_OBJ,
      p_source_selection      IN EM_RULE_EXPRESSION_ARRAY DEFAULT NULL,
      p_selected_targets      IN MGMT_MEDIUM_STRING_ARRAY DEFAULT NULL,
      p_excluded_targets      IN MGMT_MEDIUM_STRING_ARRAY DEFAULT NULL,
      p_target_types          IN EM_RULE_EXPRESSION_OBJ DEFAULT NULL)
    RETURN SELF AS RESULT );
/
   
CREATE OR REPLACE TYPE EM_RULE_SET_DETAILS_ARRAY AS VARRAY(50) OF EM_RULE_SET_DETAILS_OBJ;
/ 
  
CREATE OR REPLACE TYPE EM_RULE_HEADER_OBJ AS OBJECT
  (
    RULE_ID           NUMBER,
    RULESET_ID        NUMBER,
    RULE_NAME         VARCHAR2(256),
    RULE_NAME_NLSID   VARCHAR2(256),
    CREATED_BY        VARCHAR2(256),
    DESCRIPTION       VARCHAR2(256),
    DESCRIPTION_NLSID VARCHAR2(256),
    RESOURCE_BUNDLE   VARCHAR2(512),
    RULE_ORDER        NUMBER(11),
    IS_REFERED_ACTION NUMBER(1),
    REFERED_RULE_ID   NUMBER,
    IS_ENABLED        NUMBER(1),
    IS_BROKEN         NUMBER(1),
    CREATION_DATE     DATE,
    LAST_UPDATED_BY   VARCHAR2(256),
    LAST_UPDATED_DATE DATE,
    PLUGINID          VARCHAR2(256),
    EVENT_CLASS       VARCHAR2(20),
    PRIV_MODE NUMBER(1),
    CONSTRUCTOR FUNCTION EM_RULE_HEADER_OBJ(
        p_ruleset_id        IN NUMBER,
        p_rule_name         IN VARCHAR2,
        p_rule_name_nlsid   IN VARCHAR2 DEFAULT NULL,
        p_created_by        IN VARCHAR2,
        p_description       IN VARCHAR2,
        p_description_nlsid IN VARCHAR2 DEFAULT NULL,
        p_resource_bundle   IN VARCHAR2 DEFAULT NULL,
        p_is_refered_action IN NUMBER DEFAULT 0,
        p_refered_rule_id   IN NUMBER DEFAULT NULL,
        p_is_enabled        IN NUMBER DEFAULT 1,
        p_is_broken         IN NUMBER DEFAULT 0,
        p_priv_mode         IN NUMBER DEFAULT 0
        )
RETURN SELF AS RESULT );
/
  
  
CREATE OR REPLACE TYPE EM_RULE_HEADER_ARRAY AS VARRAY(5000) OF EM_RULE_HEADER_OBJ;
/


CREATE OR REPLACE TYPE EM_RULE_DETAILS_OBJ AS OBJECT
  (
    RULE_TYPE NUMBER,
    RL_EXPRESSION EM_RULE_RL_OBJ,
    BROKEN_REASONS EM_RULE_BROKEN_OBJ,
    RULE_HEADER EM_RULE_HEADER_OBJ,
    RULE_EXPRESSION EM_RULE_EXPRESSION_ARRAY,
    COND_ACTIONS EM_RULE_COND_ACTIONS_ARRAY,
    
    CONSTRUCTOR FUNCTION EM_RULE_DETAILS_OBJ(
      p_rule_type       IN NUMBER,
      p_rl_expression   IN EM_RULE_RL_OBJ DEFAULT NULL,
      p_broken_reasons  IN EM_RULE_BROKEN_OBJ DEFAULT NULL,
      p_rule_header     IN EM_RULE_HEADER_OBJ,
      p_rule_expression IN EM_RULE_EXPRESSION_ARRAY,
      p_cond_actions    IN EM_RULE_COND_ACTIONS_ARRAY )
    RETURN SELF AS RESULT
   );
/
  
  
CREATE OR REPLACE TYPE EM_RULE_DETAILS_ARRAY AS VARRAY(5000) OF EM_RULE_DETAILS_OBJ;
/


ALTER SESSION SET CURRENT_SCHEMA=SYSMAN_TYPES;		

CREATE OR REPLACE TYPE EM_RULE_NUMBER_ARRAY AS VARRAY(2000) OF NUMBER;
/

GRANT EXECUTE ON EM_RULE_NUMBER_ARRAY TO SYSMAN WITH GRANT OPTION;

BEGIN
    SYSMAN.CUTOVER_SYNONYM('EM_RULE_NUMBER_ARRAY');
END;
/
	   
CREATE OR REPLACE TYPE EM_RULE_EW_OBJ AS OBJECT
 (
 event_obj EM_EVENT_OBJ,
 notif_list EM_RULE_NUMBER_ARRAY,
 duration_msg_list EM_EV_BUS_DURATION_MSG_ARRAY,
 
 CONSTRUCTOR FUNCTION EM_RULE_EW_OBJ(
   p_event_obj IN EM_EVENT_OBJ,
   p_notif_list IN EM_RULE_NUMBER_ARRAY,
   p_duration_msg_list IN EM_EV_BUS_DURATION_MSG_ARRAY DEFAULT NULL)
 RETURN SELF AS RESULT
 );
/

GRANT EXECUTE ON EM_RULE_EW_OBJ TO SYSMAN WITH GRANT OPTION;

BEGIN
    SYSMAN.CUTOVER_SYNONYM('EM_RULE_EW_OBJ');
END;
/

CREATE OR REPLACE TYPE EM_RULE_IW_OBJ AS OBJECT
 (
  incident_obj EM_INCIDENT_OBJ,
  notif_list EM_RULE_NUMBER_ARRAY,
  duration_msg_list EM_EV_BUS_DURATION_MSG_ARRAY,

  CONSTRUCTOR FUNCTION EM_RULE_IW_OBJ(
    p_incident_obj IN EM_INCIDENT_OBJ,
    p_notif_list IN EM_RULE_NUMBER_ARRAY, 
    p_duration_msg_list IN EM_EV_BUS_DURATION_MSG_ARRAY DEFAULT NULL)
  RETURN SELF AS RESULT
  );
/

GRANT EXECUTE ON EM_RULE_IW_OBJ TO SYSMAN WITH GRANT OPTION;

BEGIN
    SYSMAN.CUTOVER_SYNONYM('EM_RULE_IW_OBJ');
END;
/

CREATE OR REPLACE TYPE EM_RULE_PW_OBJ AS OBJECT
 (
  problem_obj EM_PROBLEM_OBJ,
  notif_list EM_RULE_NUMBER_ARRAY,
  duration_msg_list EM_EV_BUS_DURATION_MSG_ARRAY,
  
  CONSTRUCTOR FUNCTION EM_RULE_PW_OBJ(
    p_problem_obj IN EM_PROBLEM_OBJ,
    p_notif_list IN EM_RULE_NUMBER_ARRAY,
    p_duration_msg_list IN EM_EV_BUS_DURATION_MSG_ARRAY DEFAULT NULL)
  RETURN SELF AS RESULT
  );
/


GRANT EXECUTE ON EM_RULE_PW_OBJ TO SYSMAN WITH GRANT OPTION;

BEGIN
    SYSMAN.CUTOVER_SYNONYM('EM_RULE_PW_OBJ');
END;
/

ALTER SESSION SET CURRENT_SCHEMA=SYSMAN;


CREATE OR REPLACE TYPE EM_RULE_METRIC_OBJ AS OBJECT
 (
  target_type     VARCHAR2(64),
  metric_group    VARCHAR2(64),
  metric_column   VARCHAR2(64),
  key_values      MGMT_MEDIUM_STRING_ARRAY, 
  
  CONSTRUCTOR FUNCTION EM_RULE_METRIC_OBJ(
    p_target_type    IN VARCHAR2,
    p_metric_group   IN VARCHAR2,
    p_metric_column  IN VARCHAR2,
    p_key_values     IN MGMT_MEDIUM_STRING_ARRAY)
  RETURN SELF AS RESULT  
  ); 
/ 

CREATE OR REPLACE TYPE EM_RULE_METRIC_ARRAY AS VARRAY(1000) OF EM_RULE_METRIC_OBJ;
/
show errors;

@@&EM_SQL_ROOT/core/12.2.0.0/events/rulefwk/incident_rule_types.sql


