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 » "IF FOR ANY........" help

Post new topic  Reply to topic
 "IF FOR ANY........" help « View previous topic :: View next topic » 
Author Message
brokendrum
PostPosted: Mon Nov 24, 2003 1:27 am    Post subject: "IF FOR ANY........" help Reply with quote

Apprentice

Joined: 14 Jan 2003
Posts: 34

Consider the following XML

<Message>
<Subtag>
<ValueA>123.00</ValueA>
</Subtag>
<Subtag>
<ValueB>456.00</ValueB>
</Subtag>
<Subtag>
<ValueC>789.00</ValueC>
</Subtag>
<Subtag>
<ValueD>101.00</ValueD>
</Subtag>
</Message>


The following ESQL could be used to determine if any instance of 'Subtag' contained, for example, 'ValueC':

IF FOR ANY "Message"."Subtag"[ ] AS X (X."ValueC" IS NOT NULL) THEN

But what If I wanted to map the data within 'ValueC' to a new tag? A bit like the following:

IF FOR ANY "Message"."Subtag"[ ] AS X (X."ValueC" IS NOT NULL) THEN
SET "Newtag" = X."ValueC";
END IF;


Otherwise I have to loop through each occurance of 'Subtag' until I find 'ValueC' - which makes the 'IF FOR ANY' check redundant.

Thanks,

BD
Back to top
View user's profile Send private message
wooda
PostPosted: Mon Nov 24, 2003 9:32 am    Post subject: Reply with quote

Master

Joined: 21 Nov 2003
Posts: 265
Location: UK

I read this 3 times, but I couldn't see what your question was ?
If an answer is required a question must first be presented
Back to top
View user's profile Send private message
brokendrum
PostPosted: Tue Nov 25, 2003 2:59 am    Post subject: Reply with quote

Apprentice

Joined: 14 Jan 2003
Posts: 34

Apologies. The code I suggested doesn't work - it's just what I tried because I thought it made sense. The problem is that now I've discovered there is an instance of 'Subtag' which does contains tag 'ValueC', is there an easy way of accessing the data within 'ValueC'? The only way I know how to do it is to loop through the instances of 'Subtag' checking for the occurance of 'ValueC', e.g.:

Code:

DECLARE Count, No_of_Subtags INT;

IF FOR ANY Message.Subtag[ ] AS X (X.ValueC IS NOT NULL) THEN
      SET Count = 1;
      SET No_of_Subtags = Cardinality(Message.Subtag[]);
      WHILE Count <= No_of_Subtags DO
            IF Message.Subtag[Count].ValueC IS NOT NULL THEN
                  Set............;
            END IF;
            Set Count=Count+1;
      END WHILE;
END IF;


This makes the 'IF FOR ANY ...' clause fairly pointless in this case (except for maybe some performance improvement by avoiding a while loop if no 'ValueC's are present). I just thought that if 'IF FOR ANY' can acknowledge the presence of a particular tag within a repeating structure, then it should be able to identify which instance of the repeat the tag is in and/or the data within the tag.

I've since tried the following:

Code:
SET OuputRoot.MRM.Newtag = FOR ANY Message.Subtag[] AS X (X.ValueC);


This fails stating that the value returned must be a boolean value not '789.00', so the data within 'valueC' is recognised, but how can I map it to a new tag?

Thanks,

BD
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Nov 25, 2003 6:05 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

brokendrum wrote:
I've since tried the following:

Code:
SET OuputRoot.MRM.Newtag = FOR ANY Message.Subtag[] AS X (X.ValueC);


This fails stating that the value returned must be a boolean value not '789.00', so the data within 'valueC' is recognised, but how can I map it to a new tag?


I think you want to Select or Insert.
Code:
 Set OutputRoot.MRM.NewTag = Select R.ValueC from Message.Subtag[] as R where R.ValueC IS NOT NULL;

Or something similar. You may have to play around a bit with the FROM clause to get the right thing.
_________________
I am *not* the model of the modern major general.
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 » "IF FOR ANY........" help
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.