Rem
Rem $Header: emcore/source/oracle/sysman/emdrep/sql/core/latest/emSDK/automation/sdk_job_types.sql rbali_oneoff_updated/1 2025/03/14 06:41:14 rbali Exp $
Rem
Rem sdk_job_types.sql
Rem
Rem Copyright (c) 2012, 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/emSDK/automation/sdk_job_types.sql
Rem EMRU_UNIX_DELIVERABLES:
Rem emcore/source/oracle/sysman/emdrep/sql/core/latest/emSDK/automation/sdk_job_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      sdk_job_types.sql - Job/CA SDK types
Rem
Rem    DESCRIPTION
Rem     Job/CA SDK types - separated into this file to allow documentation of
Rem     SDK. This file should NOT have an RCU header - it should be included
Rem     from latest/jobs/jobs_types.sql.
Rem
Rem    NOTES
Rem      Define all job/CA SDK types here. These should not have any
Rem      dependencies on any PL/SQL types from jobs/jobs_types.sql as this is
Rem      executed first from within jobs/jobs_types.sql.
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    lsatyapr    04/08/13 - Bug16572647 Fix ordering of type creation
Rem    jvishen     08/21/12 - Created
Rem

-- Caller should have already included the defines file (jobs/jobs_defines.sql)

ALTER SESSION SET CURRENT_SCHEMA=SYSMAN_TYPES;

-- The type that represents an array of integers
CREATE OR REPLACE TYPE MGMT_JOB_INT_ARRAY AS VARRAY(&VECTOR_ARRAY_SIZE) 
    OF INTEGER;
/

grant execute on MGMT_JOB_INT_ARRAY to sysman;

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

-- The type that represents values of a vector parameter
CREATE OR REPLACE TYPE MGMT_JOB_VECTOR_PARAMS AS VARRAY(&VECTOR_ARRAY_SIZE) 
    OF VARCHAR2(&SCALAR_VALUE_SIZE);
/

grant execute on MGMT_JOB_VECTOR_PARAMS to sysman;

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

ALTER SESSION SET CURRENT_SCHEMA=SYSMAN;

CREATE OR REPLACE TYPE MGMT_JOB_SCHEDULE_RECORD AS OBJECT 
(
    -- The frequency code for the schedule.
    frequency_code NUMBER,
    
    -- The schedule start time. Use SYSDATE if the job is to start 
    -- immediately. For daily, days of week and days of month schedules, 
    -- the start_time denotes when the job should start. Only the time part 
    -- is used, and the date part is ignored. 
    start_time DATE,

    -- For all periodic schedules, the last date (and time) to run the job. 
    -- For daily, day of week and day of month schedules, only the date 
    -- portion is used. For interval schedules, the time is taken into 
    -- account as well.
    end_time DATE,

    -- The grace period for starting the job specified in minutes. 
    -- If the job does not start between start_time and 
    -- start_time + start_grace_period it is skipped. The default of -1
    -- indicates an infinite grace period.
    start_grace_period NUMBER,

    -- The "execution time" for daily, day of week/month/year schedules. 
    -- Indicates the time of the day at which the job will execute. Hours 
    -- are specified in 24-hour format (0 to 23), and minutes is a number 
    -- between 0 and 59. 
    execution_hours NUMBER,
    execution_minutes NUMBER,

    -- The interval, in minutes for interval jobs.
    interval NUMBER,

    -- For days-of-year schedules, this indicates the "month" portion of each
    -- (month, day) pair in the schedule. The "days" portion is specified
    -- using "days", below.
    months MGMT_JOB_INT_ARRAY,

    -- For day of week/month jobs, the day(s) of the week,
    -- or month as the case may be.
    -- For days of week, this is a set of numbers from 1-7 indicating the days
    --    sunday through saturday, in that order.
    -- For days of month, this is a set of numbers from 1-31 indicating the 
    --    date of the month. A special constant called LAST_DAY (-1) 
    --    can be use for day-of-month schedules to indicate the last 
    --    day of the month.
    -- For days of the year, this is a set of numbers from 1-32 
    --    indicating the date of the month. A special constant called 
    --    LAST_DAY (-1) can be used for day-of-year schedules to indicate 
    --    the last day of the month. For day-of-year schedules, the 
    --    corresponding months are taken from the "months" field above 
    days MGMT_JOB_INT_ARRAY,

    -- Specifies which timezone the start and end times are specified in
    --    TIMEZONE_REPOSITORY: The timezone of the repository
    --    TIMEZONE_TARGET: The timezone of one of the targets in the 
    --        target list, whose index in the target list is specified 
    --        by timezone_target_index 
    --    TIMEZONE_SPECIFIED: The timezone offset is specified in the
    --       field timezone_offset
    timezone_info NUMBER,

    -- The index of the target in the target list(s) whose timezone the 
    -- times are specified in; only relevant when 
    -- timezone_info=TIMEZONE_TARGET
    timezone_target_index NUMBER,

    -- The actual timezone offset. Relevent only when
    -- timezone_info=TIMEZONE_SPECIFIED
    timezone_offset NUMBER,

    -- The actual timezone region. Relevent only when
    -- timezone_info=TIMEZONE_RGN_SPECIFIED
    timezone_region VARCHAR2(64)    
);
/

CREATE OR REPLACE TYPE MGMT_JOB_PARAM_RECORD AS OBJECT
( 
    param_name VARCHAR2(&JOB_PARAM_NAME_SIZE),
    param_type NUMBER(1),
    scalar_value VARCHAR2(&SCALAR_VALUE_SIZE),
    vector_value MGMT_JOB_VECTOR_PARAMS,
    is_safe NUMBER(1),

    -- add following functions to update scalar and vector values
    MEMBER      FUNCTION  get_scalar_value   RETURN VARCHAR2,
    MEMBER      PROCEDURE set_scalar_value   ( p_scalar_value IN VARCHAR2),
    MEMBER      FUNCTION  get_vector_length  RETURN INTEGER,
    MEMBER      FUNCTION  get_vector_element ( p_pos INTEGER ) RETURN VARCHAR2,
    MEMBER      PROCEDURE set_vector_element ( p_pos IN INTEGER, p_value IN VARCHAR2),

    CONSTRUCTOR FUNCTION MGMT_JOB_PARAM_RECORD (p_param_name VARCHAR2,
                                                p_is_safe NUMBER DEFAULT &UNSAFE_PARAM)
    RETURN SELF AS RESULT,

    CONSTRUCTOR FUNCTION MGMT_JOB_PARAM_RECORD (p_param_name VARCHAR2,
                                                p_param_type NUMBER,
                                                p_scalar_value VARCHAR2,
                                                p_vector_value MGMT_JOB_VECTOR_PARAMS)
    RETURN SELF AS RESULT,

    CONSTRUCTOR FUNCTION MGMT_JOB_PARAM_RECORD (p_param_name VARCHAR2,
                                                p_scalar_value VARCHAR2,
                                                p_is_safe NUMBER DEFAULT &UNSAFE_PARAM)
    RETURN SELF AS RESULT,

    CONSTRUCTOR FUNCTION MGMT_JOB_PARAM_RECORD (p_param_name VARCHAR2,
                                                p_vector_value MGMT_JOB_VECTOR_PARAMS,
                                                p_is_safe NUMBER DEFAULT &UNSAFE_PARAM)
    RETURN SELF AS RESULT
) NOT FINAL; 
/

CREATE OR REPLACE TYPE MGMT_JOB_PARAM_LIST AS TABLE 
       OF MGMT_JOB_PARAM_RECORD;
/

CREATE OR REPLACE TYPE MGMT_JOB_TARGET_RECORD AS OBJECT
(
    target_name VARCHAR2(256), 
    target_type VARCHAR2(64)
); 
/


CREATE OR REPLACE TYPE MGMT_JOB_TARGET_LIST AS TABLE 
       OF MGMT_JOB_TARGET_RECORD;
/

