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 » Question About Counting Element Instances in ESQL

Post new topic  Reply to topic
 Question About Counting Element Instances in ESQL « View previous topic :: View next topic » 
Author Message
goldym
PostPosted: Thu Jul 14, 2005 7:51 am    Post subject: Question About Counting Element Instances in ESQL Reply with quote

Centurion

Joined: 24 Jun 2005
Posts: 116

I have an xml that has a repeating element (A). I have to an insert a new record for each instance. I need to count each new instance and insert that value as and ID field along with each new record.

XML:
I have something similiar to this
<Tst>
<A>Table</A>
<A>Chair</A>
</Tst>


I currently have a loop for each new instance of A something like below. Does anyone know how I would add a "counter" to my loop?

DECLARE X INTEGER CARDINALITY(InputBody.(XML.Element)Tst.A[]);
DECLARE ID INTEGER 1;
DECLARE Counter INTEGER 1;
WHILE Counter <= X DO

INSERT INTO Database.TEST (furniture)
VALUES (FIELDVALUE(InputBody.(XML.Element)Trade.A[Counter]
);

SET Counter = Counter + 1; -- Increment the counter each time the while condition is sastified

END WHILE;
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Jul 14, 2005 8:07 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Um.

You already have everything you need.

Just change your Insert to insert Counter.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
goldym
PostPosted: Thu Jul 14, 2005 11:05 am    Post subject: Reply with quote

Centurion

Joined: 24 Jun 2005
Posts: 116

[quote="jefflowrey"]Um.

You already have everything you need.

Just change your Insert to insert Counter.[/quote]

Thanks Jeff, I didn't realize I had it right there:-)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Question About Counting Element Instances in ESQL
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.