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

Skip to content

Commit ec88261

Browse files
committed
Added support for printing outcomes of ref_cursors (using dbms_xmlgen.restartquery() ).
Currently the hard limit for number of rows compared is 100M, but with dbms_xmlgen we can figure a way to get around this.
1 parent 516100e commit ec88261

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

source/expectation_data_values/ut_data_value_refcursor.tpb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,14 @@ create or replace type body ut_data_value_refcursor as
2626
end;
2727

2828
overriding member function to_string return varchar2 is
29+
l_result clob;
2930
begin
30-
--TODO - implement a way to get data out of ref_cursor wothout loosing the cursor
31-
return ut_utils.to_string(to_char(null));
31+
if self.value is not null then
32+
dbms_xmlgen.setMaxRows(self.value, 100);
33+
l_result := dbms_xmlgen.getxml(self.value);
34+
dbms_xmlgen.restartQuery(self.value);
35+
end if;
36+
return ut_utils.to_string(l_result);
3237
end;
3338

3439
end;

source/expectations/equal.tpb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,14 @@ create or replace type body equal as
129129
l_expected ut_data_value_refcursor := treat(self.expected as ut_data_value_refcursor);
130130
l_actual ut_data_value_refcursor := treat(a_actual as ut_data_value_refcursor);
131131
begin
132-
l_result :=
133-
equal_with_nulls(
134-
( xmltype( dbms_sql.to_refcursor(l_expected.value) ).getClobVal
135-
= xmltype( dbms_sql.to_refcursor(l_actual.value) ).getClobVal)
136-
, a_actual
137-
);
132+
if l_expected.value is not null and l_actual.value is not null then
133+
--fetch 1M rows max
134+
dbms_xmlgen.setMaxRows(l_expected.value, 1000000);
135+
dbms_xmlgen.setMaxRows(l_actual.value, 1000000);
136+
l_result := dbms_lob.compare( dbms_xmlgen.getxml(l_expected.value), dbms_xmlgen.getxml(l_actual.value) ) = 0;
137+
else
138+
l_result := equal_with_nulls( null, a_actual);
139+
end if;
138140
end;
139141
elsif self.expected is of (ut_data_value_timestamp) and a_actual is of (ut_data_value_timestamp) then
140142
declare

0 commit comments

Comments
 (0)