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

Skip to content

Commit 290982f

Browse files
committed
Fixing ORA-00600. Seems like we cant open cursors in Initialization of package.
1 parent 457160a commit 290982f

2 files changed

Lines changed: 22 additions & 16 deletions

File tree

source/core/ut_metadata.pkb

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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;
163169
end;
164170
/

source/core/ut_utils.pkb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ create or replace package body ut_utils is
8181
case
8282
when l_len = 0 then gc_null_string
8383
when l_len <= gc_max_input_string_length then quote_string(rawtohex(a_value))
84-
else quote_string( rawtohex(dbms_lob.substr(a_value, gc_overflow_substr_len)) )
84+
else to_string( rawtohex(dbms_lob.substr(a_value, gc_overflow_substr_len)) )
8585
end;
8686
end;
8787

0 commit comments

Comments
 (0)