@@ -55,7 +55,12 @@ create or replace package body ut_compound_data_helper is
5555 a_cursor := dbms_sql.to_refcursor( l_cursor_number );
5656 l_columns_tab := get_columns_info( l_columns_desc, l_columns_count);
5757
58- select XMLELEMENT("ROW", xmlagg(xmlelement(evalname key, value))) into l_result from table(l_columns_tab );
58+ select
59+ XMLELEMENT("ROW", xmlagg(xmlelement(evalname ut_utils.xmlgen_escaped_string(key),
60+ XMLATTRIBUTES(key AS "xml_valid_name"),
61+ value)))
62+ into l_result
63+ from table(l_columns_tab );
5964
6065 return l_result;
6166 end;
@@ -89,31 +94,41 @@ create or replace package body ut_compound_data_helper is
8994 l_sql varchar2(32767);
9095 l_results tt_column_diffs;
9196 begin
92- l_column_filter := ut_compound_data_helper. get_columns_filter(a_exclude_xpath, a_include_xpath);
97+ l_column_filter := get_columns_filter(a_exclude_xpath, a_include_xpath);
9398 l_sql := q'[
9499 with
95100 expected_cols as ( select :a_expected as item_data from dual ),
96101 actual_cols as ( select :a_actual as item_data from dual ),
97- expected_cols_info as (
102+ expected_cols_info as (
98103 select e.*,
99104 replace(expected_type,'VARCHAR2','CHAR') expected_type_compare
100105 from (
101- select rownum expected_pos,
102- r.column_value.getrootelement() expected_name,
103- extractvalue(r.column_value,'/*') expected_type
104- from ( select ]'||l_column_filter||q'[ from expected_cols ucd ) s,
105- table( xmlsequence(extract(s.item_data,'/*/*')) ) r
106+ SELECT rownum expected_pos,
107+ xt.name expected_name,
108+ xt.type expected_type
109+ FROM (select ]'||l_column_filter||q'[ from expected_cols ucd) x,
110+ XMLTABLE('/ROW/*'
111+ PASSING x.item_data
112+ COLUMNS
113+ name VARCHAR2(4000) PATH '@xml_valid_name',
114+ type VARCHAR2(4000) PATH '/'
115+ ) xt
106116 ) e
107117 ),
108118 actual_cols_info as (
109119 select a.*,
110120 replace(actual_type,'VARCHAR2','CHAR') actual_type_compare
111121 from (
112- select rownum actual_pos,
113- r.column_value.getrootelement() actual_name,
114- extractvalue(r.column_value,'/*') actual_type
115- from ( select ]'||l_column_filter||q'[ from actual_cols ucd ) s,
116- table( xmlsequence(extract(s.item_data,'/*/*')) ) r
122+ SELECT rownum actual_pos,
123+ xt.name actual_name,
124+ xt.type actual_type
125+ FROM (select ]'||l_column_filter||q'[ from actual_cols ucd) x,
126+ XMLTABLE('/ROW/*'
127+ PASSING x.item_data
128+ COLUMNS
129+ name VARCHAR2(4000) PATH '@xml_valid_name',
130+ type VARCHAR2(4000) PATH '/'
131+ ) xt
117132 ) a
118133 ),
119134 joined_cols as (
@@ -152,7 +167,7 @@ create or replace package body ut_compound_data_helper is
152167 l_column_filter varchar2(32767);
153168 l_results tt_row_diffs;
154169 begin
155- l_column_filter := get_columns_filter(a_exclude_xpath, a_include_xpath);
170+ l_column_filter := get_columns_filter(a_exclude_xpath,a_include_xpath);
156171 execute immediate q'[
157172 with
158173 diff_info as (select item_no from ut_compound_data_diff_tmp ucdc where diff_id = :diff_guid and rownum <= :max_rows)
@@ -231,14 +246,14 @@ create or replace package body ut_compound_data_helper is
231246 a_hash_type binary_integer := dbms_crypto.hash_sh1
232247 ) return t_hash is
233248 l_cols_hash t_hash;
234- begin
235- if not a_data_value_cursor.is_null then
249+ begin
250+ if not a_data_value_cursor.is_null then
236251 execute immediate
237252 q'[select dbms_crypto.hash(replace(x.item_data.getclobval(),'>CHAR<','>VARCHAR2<'),]'||a_hash_type||') ' ||
238253 ' from ( select '||get_columns_filter(a_exclude_xpath, a_include_xpath)||
239254 ' from (select :columns_info as item_data from dual ) ucd' ||
240255 ' ) x'
241- into l_cols_hash using a_exclude_xpath, a_include_xpath, a_data_value_cursor.columns_info;
256+ into l_cols_hash using a_exclude_xpath,a_include_xpath, a_data_value_cursor.columns_info;
242257 end if;
243258 return l_cols_hash;
244259 end;
@@ -263,5 +278,6 @@ begin
263278 g_type_name_map( dbms_sql.number_type ) := 'NUMBER';
264279 g_type_name_map( dbms_sql.rowid_type ) := 'ROWID';
265280 g_type_name_map( dbms_sql.urowid_type ) := 'UROWID';
281+
266282end;
267283/
0 commit comments