You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/userguide/expectations.md
+26-3Lines changed: 26 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -680,13 +680,36 @@ utPLSQL is capable of comparing compound data-types including:
680
680
681
681
### Notes on comparison of compound data
682
682
- Compound data can contain elements of any data-type. This includes blob, clob, object type, nested table, varray or even a nested-cursor within a cursor.
683
-
- Cursors, nested table and varray types are compared as **ordered lists of elements**. If order of elements differ, expectation will fail.
683
+
684
+
- Nested table and varray types are compared as **ordered lists of elements**. If order of elements differ, expectation will fail.
685
+
686
+
- Cursors are compared as **unordered list of elements** by default. If order of elements is of importance the option has to be passed to enforce column order comparison `ordered_columns` e.g.
687
+
688
+
```sql
689
+
procedure ut_refcursors1 is
690
+
l_actual sys_refcursor;
691
+
l_expected sys_refcursor;
692
+
l_expected_message varchar2(32767);
693
+
l_actual_message varchar2(32767);
694
+
begin
695
+
open l_actual for select1 user_id,'s' a_col,'test' username from dual;
696
+
open l_expected for select'test' username,'s' a_col,1 user_id from dual;
- Comparison of compound data is data-type aware. So a column `ID NUMBER`in a cursor is not the same as`ID VARCHAR2(100)`, even if they both hold the same numericvalues.
703
+
685
704
- Comparison of cursor columns containing `DATE` will only compare date part **and ignore time** by default. See [Comparing cursor data containing DATE fields](#comparing-cursor-data-containing-date-fields) to check how to enable date-time comparison in cursors.
705
+
686
706
- Comparison of cursor returning `TIMESTAMP`**columns** against cursor returning `TIMESTAMP`**bind variables** requires variables to be casted to proper precision. This is an Oracle SQL - PLSQL compatibility issue and usage of CAST is the only known workaround for now.
687
-
See [Comparing cursor data containing TIMESTAMP bind variables](#comparing-cursor-data-containing-timestamp-bind-variables) for examples.
707
+
See [Comparing cursor data containing TIMESTAMP bind variables](#comparing-cursor-data-containing-timestamp-bind-variables) for examples.
708
+
688
709
- To compare nested table/varray type you need to convert it to `anydata` by using `anydata.convertCollection()`
710
+
689
711
- To compare object type you need to convert it to `anydata` by using `anydata.convertObject()`
712
+
690
713
- It is possible to compare PL/SQL records, collections, varrays and associative arrays. To compare this types of data, use cursor comparison feature of utPLSQL and TABLE operator in SQL query
691
714
-On Oracle 11g Release 2- pipelined table functions are needed (see section [Implicit (Shadow) Types in this artcile](https://oracle-base.com/articles/misc/pipelined-table-functions))
692
715
-On Oracle 12c and above - use [TABLE function on nested tables/varrays/associative arrays of PL/SQL records](https://oracle-base.com/articles/12c/using-the-table-operator-with-locally-defined-types-in-plsql-12cr1)
@@ -768,7 +791,7 @@ create or replace package body test_cursor_compare as
768
791
from dual union all
769
792
select 'M' AS GENDER, 'LUKE' as FIRST_NAME, 'SKYWALKER' AS LAST_NAME, 2 as ID, '1000' AS SALARY
|| case when l_diff_row_count > c_max_rows and l_row_diffs.count > 0 then ', showing first '||c_max_rows end
@@ -248,7 +250,7 @@ create or replace type body ut_data_value_refcursor as
248
250
end loop;
249
251
ut_utils.append_to_clob(l_result,l_results);
250
252
else
251
-
l_message:= chr(10)||'Rows: [ all different ]'||chr(10)||' All rows are different as the columns are not matching.';
253
+
l_message:= chr(10)||'Rows: [ all different ]'||chr(10)||' All rows are different as the columns position is not matching.';
252
254
ut_utils.append_to_clob( l_result, l_message );
253
255
end if;
254
256
else
@@ -304,11 +306,12 @@ create or replace type body ut_data_value_refcursor as
304
306
return self.elements_count = 0;
305
307
end;
306
308
307
-
member function filter_cursor (a_exclude_xpath ut_varchar2_list, a_include_xpath ut_varchar2_list) return ut_data_value_refcursor is
309
+
member function update_cursor_details (a_exclude_xpath ut_varchar2_list, a_include_xpath ut_varchar2_list,a_ordered_columns boolean := false) return ut_data_value_refcursor is
308
310
l_result ut_data_value_refcursor := self;
309
311
begin
310
312
if l_result.cursor_details.cursor_info is not null then
0 commit comments