@@ -104,23 +104,31 @@ create or replace package body ut_annotation_cache_manager as
104104 end;
105105
106106 procedure purge_cache(a_object_owner varchar2, a_object_type varchar2) is
107+ l_filter varchar2(32767);
108+ l_cache_filter varchar2(32767);
107109 pragma autonomous_transaction;
108110 begin
111+ if a_object_owner is null and a_object_type is null then
112+ l_filter :=
113+ case when a_object_owner is null then ':a_object_owner is null' else 'object_owner = :a_object_owner' end || '
114+ and '||case when a_object_type is null then ':a_object_type is null' else 'object_type = :a_object_type' end;
115+ l_cache_filter := ' c.cache_id
116+ in (select i.cache_id
117+ from ut_annotation_cache_info i
118+ where '|| l_filter || '
119+ )';
120+ else
121+ l_cache_filter := ':a_object_owner is null and :a_object_type is null';
122+ l_filter := l_cache_filter;
123+ end if;
109124 execute immediate '
110125 delete from ut_annotation_cache c
111- where c.cache_id
112- in (select i.cache_id
113- from ut_annotation_cache_info i
114- where 1 = 1
115- and '||case when a_object_owner is null then ':a_object_owner is null' else 'object_owner = :a_object_owner' end || '
116- and '||case when a_object_type is null then ':a_object_type is null' else 'object_type = :a_object_type' end || '
117- )'
126+ where '||l_cache_filter
118127 using a_object_owner, a_object_type;
128+
119129 execute immediate '
120130 delete from ut_annotation_cache_info i
121- where 1 = 1
122- and '||case when a_object_owner is null then ':a_object_owner is null' else 'object_owner = :a_object_owner' end || '
123- and '||case when a_object_type is null then ':a_object_type is null' else 'object_type = :a_object_type' end
131+ where ' || l_filter
124132 using a_object_owner, a_object_type;
125133 commit;
126134 end;
0 commit comments