|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
"IF FOR ANY........" help |
« View previous topic :: View next topic » |
Author |
Message
|
brokendrum |
Posted: Mon Nov 24, 2003 1:27 am Post subject: "IF FOR ANY........" help |
|
|
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 |
|
 |
wooda |
Posted: Mon Nov 24, 2003 9:32 am Post subject: |
|
|
 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 |
|
 |
brokendrum |
Posted: Tue Nov 25, 2003 2:59 am Post subject: |
|
|
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 |
|
 |
jefflowrey |
Posted: Tue Nov 25, 2003 6:05 am Post subject: |
|
|
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 |
|
 |
|
|
 |
|
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
|
|
|
|