@@ -4,11 +4,30 @@ create or replace package body ut_metadata as
44 --private definitions
55 g_source_view varchar2(32);
66
7+ function get_source_view return varchar2 is
8+ begin
9+ if g_source_view is null then
10+ declare
11+ l_cursor sys_refcursor;
12+ l_object_does_not_exist exception;
13+ pragma exception_init (l_object_does_not_exist, -942);
14+ begin
15+ g_source_view := 'dba_source';
16+ open l_cursor for 'select 1 from '||g_source_view ||' where rownum = 1';
17+ close l_cursor;
18+ exception
19+ when l_object_does_not_exist then
20+ g_source_view := 'all_source';
21+ end;
22+ end if;
23+ return g_source_view;
24+ end;
25+
726 function get_package_spec_source_cursor(a_owner varchar2 := null, a_object varchar2 := null) return sys_refcursor is
827 l_cur sys_refcursor;
928 function get_query return varchar2 is
1029 begin
11- return 'select t.text from ' || g_source_view ||
30+ return 'select t.text from ' || get_source_view() ||
1231 ' t where t.owner = :a_owner and t.name = :a_object_name and t.type = ''PACKAGE'' order by t.line';
1332 end;
1433 begin
@@ -136,7 +155,7 @@ create or replace package body ut_metadata as
136155 l_line varchar2(4000);
137156 begin
138157 execute immediate
139- 'select text from ' || g_source_view || q'[
158+ 'select text from ' || get_source_view() || q'[
140159 where owner = :a_owner and name = :a_object_name and line = :a_line_no
141160 -- skip the declarations, consider only definitions
142161 and type != 'PACKAGE' ]'
@@ -147,18 +166,5 @@ create or replace package body ut_metadata as
147166 return null;
148167 end;
149168
150- begin
151- declare
152- l_cursor sys_refcursor;
153- l_object_does_not_exist exception;
154- pragma exception_init (l_object_does_not_exist, -942);
155- begin
156- g_source_view := 'dba_source';
157- open l_cursor for 'select 1 from '||g_source_view ||' where rownum = 1';
158- close l_cursor;
159- exception
160- when l_object_does_not_exist then
161- g_source_view := 'all_source';
162- end;
163169end;
164170/
0 commit comments