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 » Strange behavior while looping

Post new topic  Reply to topic
 Strange behavior while looping « View previous topic :: View next topic » 
Author Message
Kraven12
PostPosted: Wed Feb 19, 2003 10:58 am    Post subject: Strange behavior while looping Reply with quote

Novice

Joined: 21 Oct 2001
Posts: 21

I have a need to store pieces of a message into a database under certain conditions. I am trying to create a string of all the values of that section within a loop so as to avoid writing out each field. It appears as though the concatention is not working. Any help is appreciated. Here is the code:

SET g = CARDINALITY(InputRoot.MRM.INDV_REC.*[]);
WHILE i <= g DO
EVAL('SET v = InputRoot.MRM.INDV_REC.' || FIELDNAME(InputRoot.MRM.INDV_REC.*[i]));
SET ans = ans || v;
SET i = i + 1;
END WHILE;

If I put "ans" into the usr section of the RF2 header nothing appears. If I do a "bitstream" on ans and put that into the usr section I see data.

Any idea why the string concatenation is not showing up?

Thanks in advance.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Feb 20, 2003 6:40 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

You shouldn't be using eval at all here - it's unecessary and slow.

You don't appear to have pasted the code where you initialized i (and if you're using v 2.1, you will see speed improvements if you use Reference variables instead of a Cardinality loop).

Are you trying to create a string made up of pieces like "<fieldname>.<fielddata>"?

Try something like this.
set i = 1;
set g= Cardinality(InputRoot.MRM.INDV_REC.*[]);
WHILE i <g DO
SET v = FIELDNAME(InputRoot.MRM.INDV_REC.*[i])||'.'||InputRoot.MRM.INDV_REC.*[i ];
set ans = ans||cast(v as character);
SET I=I+1;
END WHILE;

You may also be able to get what you by using just bitstream or asbitstream to flatten your tree, without having to use the loop or concatenation at all.
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 » Strange behavior while looping
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.