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

Skip to content

Commit 8f5b736

Browse files
committed
Added item_type attribute to output buffer.
Converted `text` in output bugger to be CLOB. Refactored `ut.run` to continue providing output as text.
1 parent eba2e9e commit 8f5b736

17 files changed

Lines changed: 229 additions & 109 deletions

source/api/ut.pkb

Lines changed: 72 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,10 @@ create or replace package body ut is
175175
a_client_character_set varchar2 := null
176176
) return ut_varchar2_rows pipelined is
177177
l_reporter ut_reporter_base := a_reporter;
178-
l_lines sys_refcursor;
179-
l_line varchar2(4000);
178+
l_data sys_refcursor;
179+
l_clob clob;
180+
l_item_type varchar2(32767);
181+
l_lines ut_varchar2_list;
180182
begin
181183
run_autonomous(
182184
ut_varchar2_list(),
@@ -190,13 +192,16 @@ create or replace package body ut is
190192
a_client_character_set
191193
);
192194
if l_reporter is of (ut_output_reporter_base) then
193-
l_lines := treat(l_reporter as ut_output_reporter_base).get_lines_cursor();
195+
l_data := treat(l_reporter as ut_output_reporter_base).get_lines_cursor();
194196
loop
195-
fetch l_lines into l_line;
196-
exit when l_lines%notfound;
197-
pipe row(l_line);
197+
fetch l_data into l_clob, l_item_type;
198+
exit when l_data%notfound;
199+
l_lines := ut_utils.clob_to_table(l_clob, ut_utils.gc_max_storage_varchar2_len);
200+
for i in 1 .. l_lines.count loop
201+
pipe row(l_lines(i));
202+
end loop;
198203
end loop;
199-
close l_lines;
204+
close l_data;
200205
end if;
201206
raise_if_packages_invalidated();
202207
return;
@@ -213,8 +218,10 @@ create or replace package body ut is
213218
a_client_character_set varchar2 := null
214219
) return ut_varchar2_rows pipelined is
215220
l_reporter ut_reporter_base := a_reporter;
216-
l_lines sys_refcursor;
217-
l_line varchar2(4000);
221+
l_data sys_refcursor;
222+
l_clob clob;
223+
l_item_type varchar2(32767);
224+
l_lines ut_varchar2_list;
218225
begin
219226
run_autonomous(
220227
ut_varchar2_list(),
@@ -228,13 +235,16 @@ create or replace package body ut is
228235
a_client_character_set
229236
);
230237
if l_reporter is of (ut_output_reporter_base) then
231-
l_lines := treat(l_reporter as ut_output_reporter_base).get_lines_cursor();
238+
l_data := treat(l_reporter as ut_output_reporter_base).get_lines_cursor();
232239
loop
233-
fetch l_lines into l_line;
234-
exit when l_lines%notfound;
235-
pipe row(l_line);
240+
fetch l_data into l_clob, l_item_type;
241+
exit when l_data%notfound;
242+
l_lines := ut_utils.clob_to_table(l_clob, ut_utils.gc_max_storage_varchar2_len);
243+
for i in 1 .. l_lines.count loop
244+
pipe row(l_lines(i));
245+
end loop;
236246
end loop;
237-
close l_lines;
247+
close l_data;
238248
end if;
239249
raise_if_packages_invalidated();
240250
return;
@@ -252,8 +262,10 @@ create or replace package body ut is
252262
a_client_character_set varchar2 := null
253263
) return ut_varchar2_rows pipelined is
254264
l_reporter ut_reporter_base := a_reporter;
255-
l_lines sys_refcursor;
256-
l_line varchar2(4000);
265+
l_data sys_refcursor;
266+
l_clob clob;
267+
l_item_type varchar2(32767);
268+
l_lines ut_varchar2_list;
257269
begin
258270
run_autonomous(
259271
a_paths,
@@ -267,13 +279,16 @@ create or replace package body ut is
267279
a_client_character_set
268280
);
269281
if l_reporter is of (ut_output_reporter_base) then
270-
l_lines := treat(l_reporter as ut_output_reporter_base).get_lines_cursor();
282+
l_data := treat(l_reporter as ut_output_reporter_base).get_lines_cursor();
271283
loop
272-
fetch l_lines into l_line;
273-
exit when l_lines%notfound;
274-
pipe row(l_line);
284+
fetch l_data into l_clob, l_item_type;
285+
exit when l_data%notfound;
286+
l_lines := ut_utils.clob_to_table(l_clob, ut_utils.gc_max_storage_varchar2_len);
287+
for i in 1 .. l_lines.count loop
288+
pipe row(l_lines(i));
289+
end loop;
275290
end loop;
276-
close l_lines;
291+
close l_data;
277292
end if;
278293
raise_if_packages_invalidated();
279294
return;
@@ -291,8 +306,10 @@ create or replace package body ut is
291306
a_client_character_set varchar2 := null
292307
) return ut_varchar2_rows pipelined is
293308
l_reporter ut_reporter_base := a_reporter;
294-
l_lines sys_refcursor;
295-
l_line varchar2(4000);
309+
l_data sys_refcursor;
310+
l_clob clob;
311+
l_item_type varchar2(32767);
312+
l_lines ut_varchar2_list;
296313
begin
297314
run_autonomous(
298315
a_paths,
@@ -306,13 +323,16 @@ create or replace package body ut is
306323
a_client_character_set
307324
);
308325
if l_reporter is of (ut_output_reporter_base) then
309-
l_lines := treat(l_reporter as ut_output_reporter_base).get_lines_cursor();
326+
l_data := treat(l_reporter as ut_output_reporter_base).get_lines_cursor();
310327
loop
311-
fetch l_lines into l_line;
312-
exit when l_lines%notfound;
313-
pipe row(l_line);
328+
fetch l_data into l_clob, l_item_type;
329+
exit when l_data%notfound;
330+
l_lines := ut_utils.clob_to_table(l_clob, ut_utils.gc_max_storage_varchar2_len);
331+
for i in 1 .. l_lines.count loop
332+
pipe row(l_lines(i));
333+
end loop;
314334
end loop;
315-
close l_lines;
335+
close l_data;
316336
end if;
317337
raise_if_packages_invalidated();
318338
return;
@@ -330,8 +350,10 @@ create or replace package body ut is
330350
a_client_character_set varchar2 := null
331351
) return ut_varchar2_rows pipelined is
332352
l_reporter ut_reporter_base := a_reporter;
333-
l_lines sys_refcursor;
334-
l_line varchar2(4000);
353+
l_data sys_refcursor;
354+
l_clob clob;
355+
l_item_type varchar2(32767);
356+
l_lines ut_varchar2_list;
335357
begin
336358
run_autonomous(
337359
ut_varchar2_list(a_path),
@@ -345,13 +367,16 @@ create or replace package body ut is
345367
a_client_character_set
346368
);
347369
if l_reporter is of (ut_output_reporter_base) then
348-
l_lines := treat(l_reporter as ut_output_reporter_base).get_lines_cursor();
370+
l_data := treat(l_reporter as ut_output_reporter_base).get_lines_cursor();
349371
loop
350-
fetch l_lines into l_line;
351-
exit when l_lines%notfound;
352-
pipe row(l_line);
372+
fetch l_data into l_clob, l_item_type;
373+
exit when l_data%notfound;
374+
l_lines := ut_utils.clob_to_table(l_clob, ut_utils.gc_max_storage_varchar2_len);
375+
for i in 1 .. l_lines.count loop
376+
pipe row(l_lines(i));
377+
end loop;
353378
end loop;
354-
close l_lines;
379+
close l_data;
355380
end if;
356381
raise_if_packages_invalidated();
357382
return;
@@ -369,8 +394,10 @@ create or replace package body ut is
369394
a_client_character_set varchar2 := null
370395
) return ut_varchar2_rows pipelined is
371396
l_reporter ut_reporter_base := a_reporter;
372-
l_lines sys_refcursor;
373-
l_line varchar2(4000);
397+
l_data sys_refcursor;
398+
l_clob clob;
399+
l_item_type varchar2(32767);
400+
l_lines ut_varchar2_list;
374401
begin
375402
run_autonomous(
376403
ut_varchar2_list(a_path),
@@ -384,13 +411,16 @@ create or replace package body ut is
384411
a_client_character_set
385412
);
386413
if l_reporter is of (ut_output_reporter_base) then
387-
l_lines := treat(l_reporter as ut_output_reporter_base).get_lines_cursor();
414+
l_data := treat(l_reporter as ut_output_reporter_base).get_lines_cursor();
388415
loop
389-
fetch l_lines into l_line;
390-
exit when l_lines%notfound;
391-
pipe row(l_line);
416+
fetch l_data into l_clob, l_item_type;
417+
exit when l_data%notfound;
418+
l_lines := ut_utils.clob_to_table(l_clob, ut_utils.gc_max_storage_varchar2_len);
419+
for i in 1 .. l_lines.count loop
420+
pipe row(l_lines(i));
421+
end loop;
392422
end loop;
393-
close l_lines;
423+
close l_data;
394424
end if;
395425
raise_if_packages_invalidated();
396426
return;

source/core/output_buffers/ut_output_buffer_base.tps

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ create or replace type ut_output_buffer_base authid definer as object(
1919
output_id raw(32),
2020
member procedure init(self in out nocopy ut_output_buffer_base),
2121
not instantiable member procedure close(self in ut_output_buffer_base),
22-
not instantiable member procedure send_line(self in ut_output_buffer_base, a_text varchar2),
23-
not instantiable member procedure send_lines(self in ut_output_buffer_base, a_text_list ut_varchar2_rows),
24-
not instantiable member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural := null) return ut_varchar2_rows pipelined,
22+
not instantiable member procedure send_line(self in ut_output_buffer_base, a_text varchar2, a_item_type varchar2 := null),
23+
not instantiable member procedure send_lines(self in ut_output_buffer_base, a_text_list ut_varchar2_rows, a_item_type varchar2 := null),
24+
not instantiable member procedure send_clob(self in ut_output_buffer_base, a_text clob, a_item_type varchar2 := null),
25+
not instantiable member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural := null) return ut_output_data_rows pipelined,
2526
not instantiable member function get_lines_cursor(a_initial_timeout natural := null, a_timeout_sec natural := null) return sys_refcursor,
2627
not instantiable member procedure lines_to_dbms_output(self in ut_output_buffer_base, a_initial_timeout natural := null, a_timeout_sec natural := null)
2728
) not final not instantiable

source/core/output_buffers/ut_output_buffer_tmp.sql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ create table ut_output_buffer_tmp$(
1919
*/
2020
output_id raw(32) not null,
2121
message_id number(38,0) not null,
22-
text varchar2(4000),
22+
text clob,
23+
item_type varchar2(1000),
2324
is_finished number(1,0) default 0 not null,
2425
constraint ut_output_buffer_tmp_pk primary key(output_id, message_id),
2526
constraint ut_output_buffer_tmp_ck check(is_finished = 0 and text is not null or is_finished = 1 and text is null),
2627
constraint ut_output_buffer_fk1 foreign key (output_id) references ut_output_buffer_info_tmp$(output_id)
2728
) organization index overflow nologging initrans 100
29+
lob(text) store as securefile ut_output_text(retention none)
2830
;
2931

3032
-- This is needed to be EBR ready as editioning view can only be created by edition enabled user
@@ -58,6 +60,7 @@ limitations under the License.
5860
select output_id
5961
,message_id
6062
,text
63+
,item_type
6164
,is_finished
6265
from ut_output_buffer_tmp$';
6366

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
create or replace type ut_output_data_row as object (
2+
/*
3+
utPLSQL - Version 3
4+
Copyright 2016 - 2018 utPLSQL Project
5+
6+
Licensed under the Apache License, Version 2.0 (the "License"):
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
text clob,
19+
item_type varchar2(1000)
20+
)
21+
/
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
create or replace type ut_output_data_rows as
2+
/*
3+
utPLSQL - Version 3
4+
Copyright 2016 - 2018 utPLSQL Project
5+
6+
Licensed under the Apache License, Version 2.0 (the "License"):
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
table of ut_output_data_row
19+
/

0 commit comments

Comments
 (0)