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

Skip to content

Commit 7436277

Browse files
committed
changed for loop to open-fetch-close routine to prevent optimization
1 parent 5de9091 commit 7436277

1 file changed

Lines changed: 31 additions & 12 deletions

File tree

source/core/types/ut_output_stream.tpb

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,48 @@ create or replace type body ut_output_stream as
22

33
overriding final member procedure close(self in out nocopy ut_output_stream) is
44
begin
5-
self.close( a_timeout_sec=>60 );
5+
self.close(a_timeout_sec => 60);
66
end;
77

8-
overriding final member function get_lines(a_output_id varchar2) return ut_varchar2_list pipelined is
8+
overriding final member function get_lines(a_output_id varchar2) return ut_varchar2_list
9+
pipelined is
10+
cursor l_cur is
11+
select column_value from table(self.get_lines(a_output_id, 60 * 60 * 4));
12+
l_col_value varchar2(32767);
913
begin
10-
for i in ( select column_value from table( self.get_lines(a_output_id, 60*60*4) ) ) loop
11-
pipe row(i.column_value);
14+
open l_cur;
15+
16+
-- open-fetch-close routine is used to prevent optimization as we need row by row quering
17+
loop
18+
fetch l_cur
19+
into l_col_value;
20+
exit when l_cur%notfound;
21+
pipe row(l_col_value);
1222
end loop;
23+
24+
close l_cur;
1325
return;
1426
end;
1527

16-
overriding final member function get_clob_lines(a_output_id varchar2) return ut_clob_list pipelined is
28+
overriding final member function get_clob_lines(a_output_id varchar2) return ut_clob_list
29+
pipelined is
30+
cursor l_cur is
31+
select column_value from table(self.get_clob_lines(a_output_id, 60 * 60 * 4));
32+
l_col_value clob;
1733
begin
18-
for i in ( select column_value from table( self.get_clob_lines(a_output_id, 60*60*4) ) ) loop
19-
pipe row(i.column_value);
34+
open l_cur;
35+
36+
-- open-fetch-close routine is used to prevent optimization as we need row by row quering
37+
loop
38+
fetch l_cur
39+
into l_col_value;
40+
exit when l_cur%notfound;
41+
pipe row(l_col_value);
2042
end loop;
43+
44+
close l_cur;
2145
return;
2246
end;
2347

2448
end;
2549
/
26-
--we need to use plsql optimize level=1 to prevent
27-
-- Oracle from changing the for loop to bulk collect into
28-
-- The row-by-row approach is needed to get the visible progress ot unit tests outputs
29-
-- as the tests get executed.
30-
alter type ut_output_stream compile body plsql_optimize_level = 1;

0 commit comments

Comments
 (0)