Primer Commit
This commit is contained in:
49
DB/VIEWS/REVERSE_HIERARCHICAL_VERCONSYS.sql
Normal file
49
DB/VIEWS/REVERSE_HIERARCHICAL_VERCONSYS.sql
Normal file
@@ -0,0 +1,49 @@
|
||||
--------------------------------------------------------
|
||||
-- DDL for View REVERSE_HIERARCHICAL_VERCONSYS
|
||||
--------------------------------------------------------
|
||||
|
||||
CREATE OR REPLACE FORCE EDITIONABLE VIEW "ENVX_OPER"."REVERSE_HIERARCHICAL_VERCONSYS" ("ID", "PARENT_ID", "level", "NAME", "PATH") AS
|
||||
SELECT id,
|
||||
(
|
||||
CASE
|
||||
WHEN level = 1 THEN
|
||||
NULL
|
||||
ELSE
|
||||
regexp_substr(
|
||||
sys_connect_by_path(
|
||||
id,
|
||||
'/'
|
||||
),
|
||||
'[^\/]+',
|
||||
1,
|
||||
level - 1
|
||||
)
|
||||
END
|
||||
) AS parent_id,
|
||||
level as "level",
|
||||
regexp_substr(
|
||||
level_path,
|
||||
'[^\/]+',
|
||||
1,
|
||||
level
|
||||
) AS name,
|
||||
level_path AS path
|
||||
FROM (
|
||||
SELECT ROW_NUMBER()
|
||||
OVER(
|
||||
ORDER BY level_path
|
||||
) as id,
|
||||
level_path,
|
||||
regexp_replace(
|
||||
level_path,
|
||||
'\/[^\/]+$',
|
||||
''
|
||||
) AS parent_path
|
||||
FROM hierarchical_verconsys_filter
|
||||
) h
|
||||
START WITH
|
||||
parent_path IS NULL
|
||||
CONNECT BY
|
||||
PRIOR level_path = parent_path
|
||||
ORDER BY level_path
|
||||
;
|
||||
Reference in New Issue
Block a user