@@ -55,27 +55,32 @@ create or replace package body ut_output_buffer is
5555 end;
5656
5757 function get_lines(a_reporter_id varchar2, a_timeout_sec naturaln := gc_max_wait_sec) return ut_varchar2_rows pipelined is
58- pragma autonomous_transaction;
59- l_results ut_varchar2_rows;
58+ l_buffer_data ut_varchar2_rows;
6059 l_wait_wait_time number(10,1) := 0;
6160 l_finished boolean := false;
62- begin
63- loop
61+ function get_data_from_buffer return ut_varchar2_rows is
62+ l_results ut_varchar2_rows;
63+ pragma autonomous_transaction;
64+ begin
6465 delete from (
6566 select *
6667 from ut_output_buffer_tmp where reporter_id = a_reporter_id order by message_id
6768 )
6869 returning text bulk collect into l_results;
69-
70+ commit;
71+ return l_results;
72+ end;
73+ begin
74+ loop
75+ l_buffer_data := get_data_from_buffer();
7076 --nothing fetched from output, wait and try again
71- if l_results .count = 0 then
77+ if l_buffer_data .count = 0 then
7278 dbms_lock.sleep(gc_sleep_time);
7379 l_wait_wait_time := l_wait_wait_time + gc_sleep_time;
7480 else
75- commit;
76- for i in 1 .. l_results.count loop
77- if l_results(i) is not null then
78- pipe row(l_results(i));
81+ for i in 1 .. l_buffer_data.count loop
82+ if l_buffer_data(i) is not null then
83+ pipe row(l_buffer_data(i));
7984 else
8085 l_finished := true;
8186 exit;
0 commit comments