ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » [DELETE] Duplicate Field

Post new topic  Reply to topic
 [DELETE] Duplicate Field « View previous topic :: View next topic » 
Author Message
anon_kb
PostPosted: Fri Feb 19, 2016 3:38 am    Post subject: [DELETE] Duplicate Field Reply with quote

Acolyte

Joined: 13 Nov 2014
Posts: 74

Hi all,

I just want to ask about deletion of duplicate field and retain one only. Anyway I have this structure
Code:

[b]Input[/b]

<detail>
<LineNumber>1</LineNumber>
</detail>
<detail>
<LineNumber>1</LineNumber>
</detail>
<detail>
<LineNumber>1</LineNumber>
</detail>
<detail>
<LineNumber>2</LineNumber>
</detail>

[b]Output[/b]
<detail>
<LineNumber>1</LineNumber>
</detail>
<detail>
<LineNumber>2</LineNumber>
</detail>



So far I've used this code
Code:

For source AS Environment.Variables.Temp[] DO
    IF source.LineNumber = Input.Detail[count] THEN
        DELETE FIELD Input.Detail
     END IF
     SET count = count + 1
END FOR;


Code above deletes all Details with same LineNumber
Tried to use this

Code:

For source AS Environment.Variables.Temp[] DO
    IF source.LineNumber = Input.Detail[count] THEN
        DELETE FIELD Input.Detail[count]
     END IF
     SET count = count + 1
END FOR;


It retain 1 Detail on the duplicates but it deleted the detail with no Duplicate.

Note: No debugging option here. I'm just doing this trial - comment - error debugging.


Thanks
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Feb 19, 2016 5:21 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

instead of using a counter, use 2 references.
Assuming that your list is sorted...

Compare the references:
  • Check for 1st row, move current row ref to start at row 2. Enter loop.
  • check current row with previous row ref. If the references are the same delete current row. Move current row reference to next sibling of previous row. Loop.
  • current row ref does not match previous row ref. Move previous row to current row, move current row to next sibling. Loop

Happy coding
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Fri Feb 19, 2016 7:13 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

There's a quicksort in esql implementation here somewhere, in case your tree is not sorted, either.
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
anon_kb
PostPosted: Tue Feb 23, 2016 4:14 am    Post subject: Reply with quote

Acolyte

Joined: 13 Nov 2014
Posts: 74

fjb_saper wrote:
instead of using a counter, use 2 references.
Assuming that your list is sorted...

Compare the references:
  • Check for 1st row, move current row ref to start at row 2. Enter loop.
  • check current row with previous row ref. If the references are the same delete current row. Move current row reference to next sibling of previous row. Loop.
  • current row ref does not match previous row ref. Move previous row to current row, move current row to next sibling. Loop

Happy coding



My tree is not sorted after I build it. So do i have to sort it first?
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Feb 23, 2016 6:04 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

It would help if it were, but there are techniques that will allow you to do this on an unsorted tree... The algorithm just gets a little bit more complicated because it will now involve a lookup function to determine whether you already have the tag, with a corollary to save the tag in a lookup environment if it is the first time you encounter it...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » [DELETE] Duplicate Field
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.