--------------------------------------------------------
--  DDL for View HIERARCHICAL_SCHEDULES
--------------------------------------------------------

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "ENVX_OPER"."HIERARCHICAL_SCHEDULES" ("LEVEL_ALIAS", "ID", "PARENT_ID", "GROUP_ID", "LEVEL_PATH_ID", "LEVEL_ORDER", "LEVEL_NAME", "LEVEL_STATUS", "DESCRIPTION", "LEVEL_REAL_ID") AS 
  SELECT 'S'                          AS level_alias,
           'S' || s.id_schedule         AS id,
           NULL                         AS parent_id,
           s.id_enviroment_type         AS group_id,
           to_char(s.id_schedule)       AS level_path_id,
           0                            AS level_order,
           dt.deployment_type
           || ' - '
           || s.schedule_name            AS level_name,
           1                            AS level_status,
           dt.deployment_type_desc      AS description,
           to_char(s.id_schedule)       AS level_real_id
               -------------------- FUNCTIONAL INFO -----------------------------
                ----------------------------------------------------------------
      FROM deployment_schedule    s,
           deployment_type        dt
     WHERE s.id_deployment_type = dt.id_deployment_type
    UNION ALL
    SELECT 'X'                                  AS level_alias,
           'X' || sd.id_schedule_detail         AS id, -- 'R'||id_request
           'S' || s.id_schedule                 AS parent_id,
           s.id_enviroment_type                 AS group_id,
           s.id_schedule
           || ','
           || sd.id_schedule_detail             AS level_path_id,
           0                                    AS level_order,
           sd.schedule_job_name                 AS level_name,
           1                                    AS level_status,
           sd.schedule_job_name                 AS description,
           to_char(sd.id_schedule_detail)       AS level_real_id
               -------------------- FUNCTIONAL INFO -----------------------------
                ----------------------------------------------------------------
      FROM deployment_schedule           s,
           deployment_schedule_detail    sd
     WHERE s.id_schedule = sd.id_schedule
;
