--------------------------------------------------------
--  DDL for View HIERARCHICAL_PATTERN_DEP_TECHS
--------------------------------------------------------

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "ENVX_OPER"."HIERARCHICAL_PATTERN_DEP_TECHS" ("LEVEL_ALIAS", "ID", "PARENT_ID", "GROUP_ID", "LEVEL_PATH_ID", "LEVEL_ORDER", "LEVEL_NAME", "LEVEL_STATUS", "DESCRIPTION", "LEVEL_REAL_ID") AS 
  SELECT UNIQUE 'P'                          AS level_alias,
                  'P' || p.id_pattern          AS level_id,
                  NULL                         AS parent_id,
                  p.id_deploying_tech          AS group_id,
                  to_char(p.id_pattern)      AS level_path_id,
                  0                            AS level_order,
                  p.deployment_pattern_name    AS level_name,
                  1                            AS level_status,
                  p.deployment_pattern_name    AS description,
                  p.id_pattern                 AS level_real_id
               -------------------- FUNCTIONAL INFO -----------------------------
                -----------------------------------------------------------------
      FROM deployment_pattern p
    UNION ALL
                ------------------ HIERARCHICAL INFO ------------------------------
    SELECT 'S'                          AS level_alias,
           'S' || s.id_pattern_step     AS level_id,
           'P' || s.id_pattern          AS parent_id,
           p.id_deploying_tech          AS group_id,
           p.id_pattern
           || ','
           || s.id_pattern_step AS level_path_id,
           s.exec_sequence              AS level_order,
           s.step_name                  AS level_name,
           1                            AS level_status,
           s.step_description           AS description,
           s.id_pattern_step            AS level_real_id
               -------------------- FUNCTIONAL INFO -----------------------------
                -----------------------------------------------------------------
      FROM deployment_pattern_step    s,
           deployment_pattern         p
     WHERE s.id_pattern = p.id_pattern
;
