@@ -21,15 +21,17 @@ create or replace package body ut_compound_data_helper is
2121 function get_column_info_xml(a_column_details ut_key_anyval_pair) return xmltype is
2222 l_result varchar2(4000);
2323 l_res xmltype;
24+ l_data ut_data_value := a_column_details.value;
25+ l_key varchar2(4000) := ut_utils.xmlgen_escaped_string(a_column_details.KEY);
2426 begin
25- l_result := '<'||ut_utils.xmlgen_escaped_string(a_column_details.KEY) ||' xml_valid_name="'||ut_utils.xmlgen_escaped_string(a_column_details.KEY) ||'">';
26- if a_column_details is of(ut_key_xmlvalue_pair ) then
27- l_result := l_result || (treat(a_column_details as ut_key_xmlvalue_pair).value.getstringval() );
27+ l_result := '<'||l_key ||' xml_valid_name="'||l_key ||'">';
28+ if l_data is of(ut_data_value_xmltype ) then
29+ l_result := l_result || (treat(l_data as ut_data_value_xmltype).to_string );
2830 else
29- l_result := l_result || ut_utils.xmlgen_escaped_string((treat(a_column_details as ut_key_varcharvalue_pair).value ));
31+ l_result := l_result || ut_utils.xmlgen_escaped_string((treat(l_data as ut_data_value_varchar2).data_value ));
3032 end if;
31- l_result := l_result ||'</'||ut_utils.xmlgen_escaped_string(a_column_details.KEY)||'>';
3233
34+ l_result := l_result ||'</'||l_key||'>';
3335 return xmltype(l_result);
3436 end;
3537
@@ -155,16 +157,13 @@ create or replace package body ut_compound_data_helper is
155157 return l_results;
156158 end;
157159
158- function get_pk_value (a_join_by_xpath varchar2,a_item_data xmltype) return varchar2 is
159- l_pk_value varchar2(4000) ;
160+ function get_pk_value (a_join_by_xpath varchar2,a_item_data xmltype) return clob is
161+ l_pk_value clob ;
160162 begin
161- select listagg(extractvalue(xmlelement("ROW",column_value),a_join_by_xpath),':') within group ( order by 1)
162- into l_pk_value
163- from table(xmlsequence(extract(a_item_data,'/*/*')));
164-
165- return l_pk_value;
163+ select extract(a_item_data,a_join_by_xpath).getclobval() into l_pk_value from dual;
164+ return l_pk_value;
166165 exception when no_data_found then
167- return 'null ';
166+ return 'null';
168167 end;
169168
170169 function get_rows_diff(
@@ -242,19 +241,19 @@ create or replace package body ut_compound_data_helper is
242241 unpivot ( data_item for diff_type in (exp_item as 'Expected:', act_item as 'Actual:') )
243242 )
244243 union all
245- select case when exp.pk_hash is null then 'Extra: ' else 'Missing: ' end as diff_type,
244+ select case when exp.pk_hash is null then 'Extra' else 'Missing' end as diff_type,
246245 xmlserialize(content nvl(exp.item_data, act.item_data) no indent) diffed_row,
247246 coalesce(exp.pk_hash,act.pk_hash) pk_hash,
248247 coalesce(exp.pk_value,act.pk_value) pk_value
249- from (select extract(ucd.item_data,'/*/*') item_data,i.pk_hash,
248+ from (select extract(deletexml( ucd.item_data, :join_by) ,'/*/*') item_data,i.pk_hash,
250249 ut_compound_data_helper.get_pk_value(:join_by,item_data) pk_value
251250 from ut_compound_data_tmp ucd,
252251 diff_info i
253252 where ucd.data_id = :self_guid
254253 and ucd.item_hash = i.item_hash
255254 ) exp
256255 full outer join (
257- select extract(ucd.item_data,'/*/*') item_data,i.pk_hash,
256+ select extract(deletexml( ucd.item_data, :join_by) ,'/*/*') item_data,i.pk_hash,
258257 ut_compound_data_helper.get_pk_value(:join_by,item_data) pk_value
259258 from ut_compound_data_tmp ucd,
260259 diff_info i
@@ -272,7 +271,7 @@ create or replace package body ut_compound_data_helper is
272271 a_exclude_xpath, a_include_xpath, a_expected_dataset_guid,
273272 a_join_by_xpath,
274273 a_exclude_xpath, a_include_xpath, a_actual_dataset_guid,
275- a_join_by_xpath,a_expected_dataset_guid,a_join_by_xpath, a_actual_dataset_guid,
274+ a_join_by_xpath,a_join_by_xpath, a_expected_dataset_guid,a_join_by_xpath ,a_join_by_xpath, a_actual_dataset_guid,
276275 a_max_rows;
277276
278277 return l_results;
@@ -502,7 +501,7 @@ create or replace package body ut_compound_data_helper is
502501 with xpaths_tab as (select column_value xpath from table(:xpath_tabs)),
503502 expected_column_info as ( select :expected as item_data from dual ),
504503 actual_column_info as ( select :actual as item_data from dual )
505- select xpath,diif_type from
504+ select REGEXP_SUBSTR ( xpath,'[^(/\*/)](.+)$') ,diif_type from
506505 (
507506 (select xpath,'e' diif_type from xpaths_tab
508507 minus
0 commit comments