@@ -4,14 +4,33 @@ create or replace package body ut_metadata as
44 --private definitions
55 g_source_view varchar2(32);
66
7- function get_package_spec_source_cursor(a_source_view varchar2, a_owner varchar2 := null, a_object varchar2 := null) return sys_refcursor is
8- c_query_str constant varchar2(1000) := 'select t.text from ' || a_source_view ||
9- ' t where t.owner = :a_owner and t.name = :a_object_name and t.type = ''PACKAGE'' order by t.line';
7+ function get_package_spec_source_cursor(a_owner varchar2 := null, a_object varchar2 := null) return sys_refcursor is
108 l_cur sys_refcursor;
11-
9+ l_object_does_not_exist exception;
10+ pragma exception_init (l_object_does_not_exist, -942);
11+ function get_query return varchar2 is
12+ begin
13+ return 'select t.text from ' || g_source_view ||
14+ ' t where t.owner = :a_owner and t.name = :a_object_name and t.type = ''PACKAGE'' order by t.line';
15+ end;
1216 begin
13- open l_cur for c_query_str
14- using a_owner, a_object;
17+ if g_source_view is not null then
18+ open l_cur for get_query
19+ using a_owner, a_object;
20+ else
21+ begin
22+ g_source_view := 'dba_source';
23+ open l_cur for get_query
24+ using a_owner, a_object;
25+ exception
26+ when l_object_does_not_exist then
27+ g_source_view := 'all_source';
28+
29+ open l_cur for get_query
30+ using a_owner, a_object;
31+ end;
32+ end if;
33+
1534 return l_cur;
1635 end;
1736
@@ -120,7 +139,7 @@ create or replace package body ut_metadata as
120139 begin
121140
122141 dbms_lob.createtemporary(l_source, true);
123- l_cur := get_package_spec_source_cursor(g_source_view, a_owner, a_object_name);
142+ l_cur := get_package_spec_source_cursor(a_owner, a_object_name);
124143 fetch l_cur bulk collect into l_txt_tab;
125144 for i in 1 .. cardinality(l_txt_tab) loop
126145 dbms_lob.writeappend(l_source, length(l_txt_tab(i)), l_txt_tab(i));
@@ -130,18 +149,5 @@ create or replace package body ut_metadata as
130149
131150 end get_package_spec_source;
132151
133- begin
134- declare
135- l_cursor sys_refcursor;
136- l_object_does_not_exist exception;
137- pragma exception_init (l_object_does_not_exist, -942);
138- begin
139- l_cursor := get_package_spec_source_cursor('dba_source');
140- close l_cursor;
141- g_source_view := 'dba_source';
142- exception
143- when l_object_does_not_exist then
144- g_source_view := 'all_source';
145- end;
146152end;
147153/
0 commit comments