@@ -6,31 +6,14 @@ create or replace package body ut_metadata as
66
77 function get_package_spec_source_cursor(a_owner varchar2 := null, a_object varchar2 := null) return sys_refcursor is
88 l_cur sys_refcursor;
9- l_object_does_not_exist exception;
10- pragma exception_init (l_object_does_not_exist, -942);
11- function get_query return varchar2 is
9+ function get_query return varchar2 is
1210 begin
1311 return 'select t.text from ' || g_source_view ||
1412 ' t where t.owner = :a_owner and t.name = :a_object_name and t.type = ''PACKAGE'' order by t.line';
1513 end;
1614 begin
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-
15+ open l_cur for get_query
16+ using a_owner, a_object;
3417 return l_cur;
3518 end;
3619
@@ -149,5 +132,33 @@ create or replace package body ut_metadata as
149132
150133 end get_package_spec_source;
151134
135+ function get_source_definition_line(a_owner varchar2, a_object_name varchar2, a_line_no integer) return varchar2 is
136+ l_line varchar2(4000);
137+ begin
138+ execute immediate
139+ 'select text from ' || g_source_view || q'[
140+ where owner = :a_owner and name = :a_object_name and line = :a_line_no
141+ -- skip the declarations, consider only definitions
142+ and type != 'PACKAGE' ]'
143+ into l_line using a_owner, a_object_name, a_line_no;
144+ return '"'||ltrim(rtrim( lower( l_line ), chr(10) ))||'"';
145+ exception
146+ when no_data_found then
147+ return null;
148+ end;
149+
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;
152163end;
153164/
0 commit comments