|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Multiple WHILE statements |
« View previous topic :: View next topic » |
Author |
Message
|
jdouch |
Posted: Fri May 31, 2002 8:15 am Post subject: Multiple WHILE statements |
|
|
Apprentice
Joined: 31 May 2002 Posts: 32 Location: London, UK
|
Hi,
I am trying to use a nested WHILE statement (WHILE statement within a WHILE statement), and not having much success.
I am receiving an XML message has a structure or hierarchy of a Parent, Mulitple Children and mulitple grandchildren. I need to loop through the message and propagate a message for each of the grandchildren, the only problem being for each message i need information to be sent from the child header.
I am currently using a nested WHILE statement, and the PROPAGATE function to send out the messages at the end of the WHILE statement. I have the inner loop working which sends out 4 messages for the grandchildren of the first child, but it appears that once this has finished it does not step out of the nested statement and move to the next child.
so has anyone successfully used a nested WHILE statement or any ideas on how to ?
my code at the moment is as follows:
DECLARE C INT;
DECLARE i INT;
SET C = 1;
SET i = 1;
WHILE
DECLARE C INT;
SET C = 1;
DECLARE i INT;
SET i = 1;
WHILE C <= CARDINALITY(InputRoot.XML."ASNEnvelope"."ASN"[]) DO
WHILE i <= CARDINALITY(InputRoot.XML."ASNEnvelope"."ASN"."ASNItem"[]) DO
"XML data Mappings here "
PROPAGATE;
SET i = i+1;
END WHILE;
SET C = C+1;
END WHILE;
RETURN FALSE;
RETURN FALSE;
thanks in advance _________________ Julian Douch
E-business Solutions Consultant
WMQ/WMQI Specialist |
|
Back to top |
|
 |
kirani |
Posted: Fri May 31, 2002 9:19 am Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
Julian,
Your ESQL should look like this,
Code: |
DECLARE CHILDCNT INT;
DECLARE CHILDTOT INT;
DECLARE GCHILDCNT INT;
DECLARE GCHILDTOT INT;
SET CHILDTOT=CARDINALITY(InputRoot.XML."ASNEnvelope"."ASN"[];
SET CHILDCNT=1;
WHILE CHILDCNT <= CHILDTOT DO
SET GCHILDCNT=1;
SET GCHILDTOT = CARDINALITY(InputRoot.XML."ASNEnvelope"."ASN"[CHILDCNT]."ASNItem"[];
WHILE GCHILDCNT <= GCHILDTOT DO
/*
XML data Mappings here
While mapping refer to input element using InputRoot.XML."ASNEnvelope"."ASN"[CHILDCNT]."ASNItem"[GCHILDCNT] */
PROPAGATE;
SET GCHILDCNT = GCHILDCNT + 1;
END WHILE;
SET CHILDCNT = CHILDCNT + 1;
END WHILE;
RETURN FALSE; |
_________________ Kiran
IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries
|
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|