@@ -234,6 +234,13 @@ create or replace type body ut_compound_data_value as
234234 **/
235235 execute immediate 'merge into ' || l_ut_owner || '.ut_compound_data_tmp tgt
236236 using (
237+ select ucd_out.item_hash,
238+ ucd_out.pk_hash,
239+ ucd_out.item_no,
240+ ucd_out.data_id,
241+ row_number() over (partition by ucd_out.pk_hash,ucd_out.item_hash,ucd_out.data_id order by 1,2) duplicate_no
242+ from
243+ (
237244 select '||l_ut_owner ||'.ut_compound_data_helper.get_hash(ucd.item_data.getclobval()) item_hash,
238245 pk_hash, ucd.item_no, ucd.data_id
239246 from
@@ -242,47 +249,49 @@ create or replace type body ut_compound_data_value as
242249 from ' || l_ut_owner || q'[.ut_compound_data_tmp ucd
243250 where data_id = :self_guid or data_id = :other_guid
244251 ) ucd
252+ )ucd_out
245253 ) src
246254 on (tgt.item_no = src.item_no and tgt.data_id = src.data_id)
247255 when matched then update
248256 set tgt.item_hash = src.item_hash,
249- tgt.pk_hash = src.pk_hash ]'
257+ tgt.pk_hash = src.pk_hash,
258+ tgt.duplicate_no = src.duplicate_no]'
250259 using a_exclude_xpath, a_include_xpath,a_join_by_xpath,self.data_id, l_other.data_id;
251260
252261 /* Peform minus on two sets two get diffrences that will be used later on to print results */
253262 execute immediate 'insert into ' || l_ut_owner || '.ut_compound_data_diff_tmp ( diff_id,item_hash,pk_hash,duplicate_no)
254263 with source_data as
255- ( select t.data_id,t.item_hash,row_number() over (partition by t.pk_hash,t.item_hash,t.data_id order by 1,2) duplicate_no,
264+ ( select t.data_id,t.item_hash,t. duplicate_no,
256265 pk_hash
257266 from ' || l_ut_owner || '.ut_compound_data_tmp t
258267 where data_id = :self_guid or data_id = :other_guid
259268 )
260269 select distinct :diff_id,tmp.item_hash,tmp.pk_hash,tmp.duplicate_no
261270 from(
262271 (
263- select t.item_hash,t. duplicate_no,t.pk_hash
272+ select t.item_hash,t.duplicate_no,t.pk_hash
264273 from source_data t
265274 where t.data_id = :self_guid
266275 minus
267- select t.item_hash,t. duplicate_no,t.pk_hash
276+ select t.item_hash,t.duplicate_no,t.pk_hash
268277 from source_data t
269278 where t.data_id = :other_guid
270279 )
271280 union all
272281 (
273- select t.item_hash,t. duplicate_no,t.pk_hash
282+ select t.item_hash,t.duplicate_no,t.pk_hash
274283 from source_data t
275284 where t.data_id = :other_guid
276285 minus
277- select t.item_hash,t. duplicate_no,t.pk_hash
286+ select t.item_hash,t.duplicate_no,t.pk_hash
278287 from source_data t
279288 where t.data_id = :self_guid
280289 ))tmp'
281290 using self.data_id, l_other.data_id,
282291 l_diff_id,
283292 self.data_id, l_other.data_id,
284293 l_other.data_id,self.data_id;
285- --result is OK only if both are same
294+ --result is OK only if both are same
286295 if sql%rowcount = 0 and self.elements_count = l_other.elements_count then
287296 l_result := 0;
288297 else
0 commit comments