Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b6b5067

Browse files
committed
added function parse_package_annotations(a_source clob) return typ_annotated_package call to specification, marked as internal use only
made source view determination "lazy" on first execution
1 parent a009558 commit b6b5067

3 files changed

Lines changed: 33 additions & 24 deletions

File tree

source/ut_annotations.pkb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ create or replace package body ut_annotations as
101101

102102
end get_annotations;
103103

104-
function get_package_annotations(a_source varchar2, a_comments tt_comment_list) return tt_annotations is
104+
function get_package_annotations(a_source clob, a_comments tt_comment_list) return tt_annotations is
105105
l_package_comments varchar2(32767);
106106
begin
107107
l_package_comments := regexp_substr(srcstr => a_source
@@ -116,7 +116,7 @@ create or replace package body ut_annotations as
116116
end;
117117
end;
118118

119-
function get_procedure_annotations(a_source varchar2, a_comments tt_comment_list) return tt_procedure_annotations is
119+
function get_procedure_annotations(a_source clob, a_comments tt_comment_list) return tt_procedure_annotations is
120120
l_proc_comments varchar2(32767);
121121
l_proc_name t_annotation_name;
122122
l_annot_proc_ind number;

source/ut_annotations.pks

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,11 @@ create or replace package ut_annotations as
4949
type typ_annotated_package is record(
5050
procedure_annotations tt_procedure_annotations
5151
,package_annotations tt_annotations);
52-
53-
52+
53+
/*
54+
INTERNAL USE ONLY
55+
*/
56+
function parse_package_annotations(a_source clob) return typ_annotated_package;
5457

5558
/*
5659
function: get_package_annotations

source/ut_metadata.pkb

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -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;
146152
end;
147153
/

0 commit comments

Comments
 (0)