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 » DETACH within a while loop

Post new topic  Reply to topic
 DETACH within a while loop « View previous topic :: View next topic » 
Author Message
EnOne
PostPosted: Thu Aug 18, 2005 10:01 am    Post subject: DETACH within a while loop Reply with quote

Centurion

Joined: 09 Oct 2002
Posts: 100
Location: Kansas City

I have something like the following
Code:

<Parent>
   <Child>
      <Grand>A<Grand>
   </Child>
   <Child>
      <Grand>A<Grand>
   </Child>
   <Child>
      <Grand>C<Grand>
   </Child>
   <Child>
      <Grand>A<Grand>
   </Child>
   <Child>
      <Grand>A<Grand>
   </Child>
</Parent>


and I tried to remove the C Child by doing this

Code:

DECLARE Ch REFERENCE TO Environment.XML.Parent.Child;
WHILE LASTMOVE(Ch) = YES DO
   IF Ch.Grand = 'C' THEN
       DETACH Ch;
   END IF;
   MOVE Ch NEXTCHILD;
END WHILE;


to get this
Code:

<Parent>
   <Child>
      <Grand>A<Grand>
   </Child>
   <Child>
      <Grand>A<Grand>
   </Child>
   <Child>
      <Grand>A<Grand>
   </Child>
   <Child>
      <Grand>A<Grand>
   </Child>
</Parent>




but it does not work. has anyone had success doing something like this. I am trying to do this using references since in the actual code there are hundreds of children.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Aug 18, 2005 10:13 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

http://www.mqseries.net/phpBB2/viewtopic.php?t=23807
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
EnOne
PostPosted: Thu Aug 18, 2005 12:30 pm    Post subject: Reply with quote

Centurion

Joined: 09 Oct 2002
Posts: 100
Location: Kansas City

What finally worked was this

Code:

DECLARE Y INTEGER 1;
WHILE LASTMOVE(Ch) = YES DO
   IF Ch.Grand = 'C' THEN
      MOVE Ch NEXTSIBLING;
      SET Environment.XML.Parent.Child[Y] = NULL;
      DECLARE Ch REFERENCE TO Environment.XML.Parent.Child[Y];
   ELSE
      SET Y = Y + 1;  --increment output
      MOVE Ch NEXTSIBLING;
   END IF;   
END WHILE;


I was unable to get DETACH to work within a while loop so I had to use a counter
Back to top
View user's profile Send private message
elvis_gn
PostPosted: Thu Aug 18, 2005 8:08 pm    Post subject: Reply with quote

Padawan

Joined: 08 Oct 2004
Posts: 1905
Location: Dubai

Wouldn't this work

DECLARE Ch REFERENCE TO Environment.XML.Parent.Child;
WHILE LASTMOVE(Ch) DO
IF Ch.Grand = 'C' THEN
MOVE Ch NEXTCHILD;
DELETE PREVIOUSSIBLING OF Ch;
ELSE
MOVE Ch NEXTCHILD;
END IF;
END WHILE;

I'm using DELETE since it seems that u do not want the segment in the output.

Regards.
Back to top
View user's profile Send private message Send e-mail
javaforvivek
PostPosted: Fri Aug 19, 2005 12:39 am    Post subject: Reply with quote

Master

Joined: 14 Jun 2002
Posts: 282
Location: Pune,India

I agree with elvis_gn.
njpeeke why can you not use DELETE statement?
_________________
Vivek
------------------------------------------------------
...when you have eliminated the impossible, whatever remains, however improbable, must be the truth.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » DETACH within a while loop
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.