@@ -125,51 +125,63 @@ create or replace package body ut_suite_cache_manager is
125125
126126 Fourth SQL cover scenario where suitepath is populated with no filters
127127 */
128-
129- --TODO: Przenies w osobny with clause z nazwami jako opis.
130- -- i with clause na tablice.
131128 function expand_paths(a_schema_paths ut_path_items) return ut_path_items is
132129 l_schema_paths ut_path_items:= ut_path_items();
133130 begin
134- with paths_to_expand as (
131+ with
132+ schema_paths as (
133+ select * from table(a_schema_paths)
134+ ),
135+ paths_for_object as (
135136 select /*+ no_parallel */ min(path) as suite_path,sp.schema_name as schema_name,nvl(c.object_name,sp.object_name) as object_name,
136137 null as procedure_name
137- from table(a_schema_paths) sp left outer join ut_suite_cache c
138+ from schema_paths sp left outer join ut_suite_cache c
138139 on ( c.object_owner = upper(sp.schema_name)
139140 and c.object_name like replace(upper(sp.object_name),'*','%'))
140141 where sp.suite_path is null and sp.object_name is not null
141142 and ( sp.procedure_name is null or sp.procedure_name = '*')
142143 group by sp.schema_name,nvl(c.object_name,sp.object_name)
143- union all
144+ ),
145+ paths_for_procedures as (
144146 select /*+ no_parallel */ path as suite_path,sp.schema_name as schema_name,nvl(c.object_name,sp.object_name) as object_name,
145147 nvl(c.name,sp.procedure_name) as procedure_name
146- from table(a_schema_paths) sp left outer join ut_suite_cache c
148+ from schema_paths sp left outer join ut_suite_cache c
147149 on ( c.object_owner = upper(sp.schema_name)
148150 and c.object_name like replace(upper(sp.object_name),'*','%')
149151 and c.name like nvl(replace(upper(sp.procedure_name),'*','%'), c.name))
150152 where sp.suite_path is null and sp.object_name is not null
151153 and (sp.procedure_name is not null and sp.procedure_name != '*')
152- union all
154+ ),
155+ paths_for_suite_path_with_ast as (
153156 select /*+ no_parallel */ nvl(c.path,sp.suite_path) as suite_path,sp.schema_name,sp.object_name,sp.procedure_name as procedure_name
154- from
155- table(a_schema_paths) sp left outer join ut_suite_cache c on
157+ from schema_paths sp left outer join ut_suite_cache c on
156158 ( c.object_owner = upper(sp.schema_name)
157159 and c.path like replace(sp.suite_path,'*','%'))
158160 where sp.suite_path is not null and instr(sp.suite_path,'*') > 0
159- union all
161+ ),
162+ straigth_suite_paths as (
160163 select /*+ no_parallel */ sp.suite_path as suite_path,sp.schema_name,sp.object_name,sp.procedure_name as procedure_name
161- from table(a_schema_paths) sp
164+ from schema_paths sp
162165 where
163166 (sp.suite_path is not null and instr(sp.suite_path,'*') = 0)
164167 or
165168 (sp.suite_path is null and sp.object_name is null)
169+ ),
170+ all_suitepaths_together as (
171+ select * from paths_for_object
172+ union all
173+ select * from paths_for_procedures
174+ union all
175+ select * from paths_for_suite_path_with_ast
176+ union all
177+ select * from straigth_suite_paths
166178 )
167179 select ut_path_item(schema_name,object_name,procedure_name,suite_path)
168180 bulk collect into l_schema_paths
169181 from
170182 (select schema_name,object_name,procedure_name,suite_path,
171183 row_number() over ( partition by schema_name,object_name,procedure_name,suite_path order by 1) as r_num
172- from paths_to_expand )
184+ from all_suitepaths_together )
173185 where r_num = 1 ;
174186 return l_schema_paths;
175187 end;
0 commit comments