Posted: Thu Jul 14, 2005 7:51 am Post subject: Question About Counting Element Instances in ESQL
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
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