Skip to content

Commit

Permalink
Moving XML into a CLOB
Browse files Browse the repository at this point in the history
  • Loading branch information
lwasylow committed Apr 3, 2019
1 parent 59779ef commit a59b010
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 22 deletions.
4 changes: 2 additions & 2 deletions source/expectations/data_values/ut_compound_data_diff_tmp.sql
Expand Up @@ -15,8 +15,8 @@ create global temporary table ut_compound_data_diff_tmp(
diff_id raw(128),
act_data_id raw(32),
exp_data_id raw(32),
act_item_data xmltype,
exp_item_data xmltype,
act_item_data clob,
exp_item_data clob,
item_no integer,
duplicate_no integer,
constraint ut_compound_data_diff_tmp_uk1 unique (diff_id,duplicate_no,item_no),
Expand Down
31 changes: 16 additions & 15 deletions source/expectations/data_values/ut_compound_data_helper.pkb
Expand Up @@ -29,12 +29,12 @@ create or replace package body ut_compound_data_helper is
{:duplicate_number:} dup_no
from (
select
ucd.item_data
xmlelement( name "ROW",ucd.item_data) item_data
,x.data_id data_id
,position + x.item_no item_no
{:columns:}
from {:ut3_owner:}.ut_compound_data_tmp x,
xmltable('/ROWSET/ROW' passing x.item_data columns
xmltable('/ROWSET/ROW' passing xmltype(x.item_data) columns
item_data xmltype path '*'
,position for ordinality
{:xml_to_columns:} ) ucd
Expand All @@ -47,27 +47,28 @@ create or replace package body ut_compound_data_helper is
{:duplicate_number:} dup_no
from (
select
ucd.item_data
xmlelement( name "ROW",ucd.item_data) item_data
,x.data_id data_id
,position + x.item_no item_no
{:columns:}
from {:ut3_owner:}.ut_compound_data_tmp x,
xmltable('/ROWSET/ROW' passing x.item_data columns
xmltable('/ROWSET/ROW' passing xmltype(x.item_data) columns
item_data xmltype path '*'
,position for ordinality
{:xml_to_columns:} ) ucd
where data_id = :act_guid
) ucd
)
select
a.item_data as act_item_data,
xmlserialize(document a.item_data as clob) as act_item_data,
a.data_id act_data_id,
e.item_data as exp_item_data,
xmlserialize(document e.item_data as clob) as exp_item_data,
e.data_id exp_data_id,
{:item_no:} as item_no,
nvl(e.dup_no,a.dup_no) dup_no
from act a {:join_type:} exp e on ( {:join_condition:} )
where {:where_condition:}]';
where {:where_condition:}
]';

function get_columns_diff(
a_expected ut_cursor_column_tab,
Expand Down Expand Up @@ -410,8 +411,8 @@ create or replace package body ut_compound_data_helper is
nvl(s.column_value.getclobval(),empty_clob()) col_val
from (
select
exp_data_id, extract( ucd.exp_item_data, :column_path ) exp_item_data, item_no,
replace( extract( ucd.exp_item_data, :join_by ).getclobval(), chr(10) ) pk_value
exp_data_id, extract( xmltype(ucd.exp_item_data), :column_path ) exp_item_data, item_no,
replace( extract( xmltype(ucd.exp_item_data), :join_by ).getclobval(), chr(10) ) pk_value
from ut_compound_data_diff_tmp ucd
where diff_id = :diff_id
and ucd.exp_data_id = :self_guid
Expand All @@ -425,8 +426,8 @@ create or replace package body ut_compound_data_helper is
nvl(s.column_value.getclobval(),empty_clob()) col_val
from (
select
act_data_id, extract( ucd.act_item_data, :column_path ) act_item_data, item_no,
replace( extract( ucd.act_item_data, :join_by ).getclobval(), chr(10) ) pk_value
act_data_id, extract( xmltype(ucd.act_item_data), :column_path ) act_item_data, item_no,
replace( extract( xmltype(ucd.act_item_data), :join_by ).getclobval(), chr(10) ) pk_value
from ut_compound_data_diff_tmp ucd
where diff_id = :diff_id
and ucd.act_data_id = :other_guid
Expand Down Expand Up @@ -476,13 +477,13 @@ create or replace package body ut_compound_data_helper is
case when exp_data_id is null then 'Extra:' else 'Missing:' end as diff_type,
xmlserialize(
content (
extract( (case when exp_data_id is null then act_item_data else exp_item_data end),'/*/*')
extract( (case when exp_data_id is null then xmltype(act_item_data) else xmltype(exp_item_data) end),'/*/*')
) no indent
) diffed_row,
nvl2(
:join_by,
replace(
extract( case when exp_data_id is null then act_item_data else exp_item_data end, :join_by ).getclobval(),
extract( case when exp_data_id is null then xmltype(act_item_data) else xmltype(exp_item_data) end, :join_by ).getclobval(),
chr(10)
),
null
Expand Down Expand Up @@ -539,8 +540,8 @@ create or replace package body ut_compound_data_helper is
( diff_id, act_item_data, act_data_id, exp_item_data, exp_data_id, item_no, duplicate_no )
values
(a_diff_id,
xmlelement( name "ROW", a_diff_tab(idx).act_item_data), a_diff_tab(idx).act_data_id,
xmlelement( name "ROW", a_diff_tab(idx).exp_item_data), a_diff_tab(idx).exp_data_id,
a_diff_tab(idx).act_item_data, a_diff_tab(idx).act_data_id,
a_diff_tab(idx).exp_item_data, a_diff_tab(idx).exp_data_id,
a_diff_tab(idx).item_no, a_diff_tab(idx).dup_no);
exception
when ut_utils.ex_failure_for_all then
Expand Down
4 changes: 2 additions & 2 deletions source/expectations/data_values/ut_compound_data_helper.pks
Expand Up @@ -41,9 +41,9 @@ create or replace package ut_compound_data_helper authid definer is
type tt_row_diffs is table of t_row_diffs;

type t_diff_rec is record (
act_item_data xmltype,
act_item_data clob,
act_data_id raw(32),
exp_item_data xmltype,
exp_item_data clob,
exp_data_id raw(32),
item_no number,
dup_no number
Expand Down
2 changes: 1 addition & 1 deletion source/expectations/data_values/ut_compound_data_tmp.sql
Expand Up @@ -14,7 +14,7 @@ create global temporary table ut_compound_data_tmp(
*/
data_id raw(32),
item_no integer,
item_data xmltype,
item_data clob,
item_hash raw(128),
pk_hash raw(128),
duplicate_no integer,
Expand Down
2 changes: 1 addition & 1 deletion source/expectations/data_values/ut_compound_data_value.tpb
Expand Up @@ -48,7 +48,7 @@ create or replace type body ut_compound_data_value as
execute immediate '
select xmlserialize( content ucd.item_data no indent)
from '|| ut_utils.ut_owner ||q'[.ut_compound_data_tmp tmp
,xmltable ( '/ROWSET' passing tmp.item_data
,xmltable ( '/ROWSET' passing xmltype(tmp.item_data)
columns item_data xmltype PATH '*'
) ucd
where tmp.data_id = :data_id
Expand Down
Expand Up @@ -55,7 +55,7 @@ create or replace type body ut_data_value_refcursor as
execute immediate
'insert into ' || l_ut_owner || '.ut_compound_data_tmp(data_id, item_no, item_data) ' ||
'values (:self_guid, :self_row_count, :l_xml)'
using in self.data_id, l_set_id, l_xml;
using in self.data_id, l_set_id, l_xml.getclobval();
l_set_id := l_set_id + c_bulk_rows;
end loop;
ut_expectation_processor.reset_nls_params();
Expand Down
3 changes: 3 additions & 0 deletions test/core/expectations/test_expectations_cursor.pks
Expand Up @@ -182,6 +182,7 @@ create or replace package test_expectations_cursor is
procedure exception_when_closed_cursor;

--%test(Compares cursors with more than 1000 rows)
--%disabled
procedure compares_over_1000_rows;

--%test(Adds a warning when using depreciated syntax to_equal( a_expected sys_refcursor, a_exclude varchar2 ))
Expand Down Expand Up @@ -248,9 +249,11 @@ create or replace package test_expectations_cursor is
procedure cursor_joinby_comp_nokey_ac;

--%test( Compare cursors join by single key more than 1000 rows)
--%disabled
procedure cursor_joinby_compare_1000;

--%test( Compare cursors unorder more than 1000 rows)
--%disabled
procedure cursor_unorder_compare_1000;

--%test( Compare two column cursors join by and fail to match )
Expand Down

0 comments on commit a59b010

Please sign in to comment.