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 » SELECT return value filtered using attribute value?

Post new topic  Reply to topic
 SELECT return value filtered using attribute value? « View previous topic :: View next topic » 
Author Message
adamcadaver
PostPosted: Wed Nov 27, 2013 9:04 am    Post subject: SELECT return value filtered using attribute value? Reply with quote

Newbie

Joined: 27 Nov 2013
Posts: 4

I am trying to return the value of a element in an example message based on attribute value of the parent

the structure of the XML message is:

Code:
<transaction>
    <operation>
        <column name="A">
            <item>Desired Value</item>
        </column>
        <column name="B">
            <item>Other Value</item>
        </column>
    </operation>
</transaction>


In XPath this would be done in with the following query:

Code:
/transaction/operation/column[@name='A']/item/test()


But In ESQL I can not get it to work. I'm thinking it should be something akin to:

Code:
DECLARE variable ROW;

SET variable[] = (
    SELECT
        FIELDVALUE(C.column.item)
    FROM
        InputRoot.XMLNSC.transaction.operation as C
    WHERE
        FIELDVALUE(C.column.(XML.Attribute)name) = "A"


Help would be much appreciated!!!


Last edited by adamcadaver on Wed Nov 27, 2013 11:58 am; edited 3 times in total
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Nov 27, 2013 9:28 am    Post subject: Re: SELECT return value filtered using attribute value? Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

adamcadaver wrote:
Help would be much appreciated!!!


When you tried it, what happened?

What version of WMB are you using?

If you're using (as you should) the XMLNSC domain and not the depreciated XML one, it's XMLNSC.Attribute you should be casting as.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
adamcadaver
PostPosted: Wed Nov 27, 2013 11:57 am    Post subject: Reply with quote

Newbie

Joined: 27 Nov 2013
Posts: 4

I tried to assign the return value of the SELECT function to a row variable

Code:
DECLARE variable ROW;

SET variable[] = ...


the flow deployed but the variable was not assigned a value when executed.

I am using WMB 7.0.0.6

My apologies indeed I am using the XMLNSC domain and I have updated my original post to reflect this.

Thank you for your reply Vitor!
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Nov 27, 2013 12:51 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

adamcadaver wrote:
the flow deployed but the variable was not assigned a value when executed.


Best advice in this sort of situation is to take a user trace (which is distinct from using a Trace node) and see exactly what's going on.

A Trace node might be valuable to ensure that the message tree (including the presence or absence of attributes) is exactly what you think it is.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
kimbert
PostPosted: Wed Nov 27, 2013 2:34 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

You should not use XML.Attribute ( or indeed XML.anything ) when dealing with a tree owned by XMLNSC. This might work better:
Code:
DECLARE variable ROW;

SET variable[] = (
    SELECT
        FIELDVALUE(C.column.item)
    FROM
        InputRoot.XMLNSC.transaction.operation as C
    WHERE
        FIELDVALUE(C.column.(XMLNSC.Attribute)name) = "A"

_________________
Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too.
Back to top
View user's profile Send private message
adamcadaver
PostPosted: Thu Nov 28, 2013 7:10 am    Post subject: Reply with quote

Newbie

Joined: 27 Nov 2013
Posts: 4

Unfortunately does that not work either.

Is it possible to use a XML attribute this way in a WHERE statement in ESQL?
Back to top
View user's profile Send private message
Simbu
PostPosted: Thu Nov 28, 2013 8:03 am    Post subject: Reply with quote

Master

Joined: 17 Jun 2011
Posts: 289
Location: Tamil Nadu, India

If I'm able to get your code work with small changes then you should also get the same result.

1) It should be like SET variable.something[] =
2)FIELDVALUE(C.column.(XMLNSC.Attribute)name) = 'A'
Back to top
View user's profile Send private message
adamcadaver
PostPosted: Fri Nov 29, 2013 1:38 am    Post subject: Reply with quote

Newbie

Joined: 27 Nov 2013
Posts: 4

Yep solved. This issue I was facing was that the 'desired value' was CDATA. I have worked around this as follows:

DECLARE reftemp ROW;
DECLARE tempValue CHAR;

SET reftemp = THE (
SELECT C.item
FROM InputRoot.XMLNSC.transaction.operation.column[] AS C
WHERE C.(XMLNSC.Attribute)name = 'A'
);

SET tempValue = reftemp.item;

Thank you so much for your help guys!

- Adam
Back to top
View user's profile Send private message
Simbu
PostPosted: Fri Nov 29, 2013 2:14 am    Post subject: Reply with quote

Master

Joined: 17 Jun 2011
Posts: 289
Location: Tamil Nadu, India

Please use code tag when you are posting code.

Quote:
Use a SELECT statement to return a scalar value by including both the THE and ITEM keywords


Code:
DECLARE tempValue CHAR;

SET tempValue = THE (
SELECT ITEM C.item
FROM InputRoot.XMLNSC.transaction.operation.column[] AS C
WHERE C.(XMLNSC.Attribute)name = 'A'
);
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 » SELECT return value filtered using attribute value?
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.