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 statement help required for XML messages

Post new topic  Reply to topic
 SELECT statement help required for XML messages « View previous topic :: View next topic » 
Author Message
aks
PostPosted: Tue Jan 13, 2004 4:46 pm    Post subject: SELECT statement help required for XML messages Reply with quote

Voyager

Joined: 19 Jul 2002
Posts: 84

I have the following XML:

<A>
<Type>type1</Type>
<Name>name1</Name>
<Value>value1</Value>
<Name>name2</Name>
<Value>value2</Value>
<Name>name2</Name>
<Value>value2</Value>
</A>
and I want to get the value of say value2 supplying name2 as an input
I use a schema, but for simplicity the equivalent DTD is:

<!-- ELEMENT A (Type, (Name, Value)+) -->

I tried:

SET value2 = THE(SELECT ITEM s.Value FROM A AS s WHERE A.Type = 'type1' AND A.Name = 'name2' );

but it doesn't work. (Seems to work if I wanted value1 using name1 as the input)

My feeling is I need an inner select, by selecting all the Name/Value pairs and then using a THE(SELECT ITEM to get the one I want.

If this is so, can someone please help with the syntax, or if there is a better way, please let me know. I'm using MRM XML.

Thanks
Alan
Back to top
View user's profile Send private message
aks
PostPosted: Tue Jan 13, 2004 4:55 pm    Post subject: Reply with quote

Voyager

Joined: 19 Jul 2002
Posts: 84

sorry, the esql statment was meant to be:

SET value2Variable = THE(SELECT ITEM s.Value FROM A AS s WHERE s.Type = 'type1' AND s.Name = 'name2' );
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Jan 13, 2004 6:19 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

If the names and the values are really siblings of each other, I think you are out of luck. There is usually no "relationship" between different siblings that you can make use of - they merely appear as sibling elements in the tree in "document order" (whatever order they happened to be encountered by the parser).

If you are positive that your tags will appear in numerical order (name1 and then value1 and then name2 and etc.), then you can get the next sibling of the appropriate name element. But if value three ever shows up as the next sibling of name2, your code isn't going to work.

Otherwise, you can change your XML so that there *is* a relationship between the names and values. Examples:
  • <name>Name1<value>Value1</value></name> (nest the values inside the names)
  • <value name="name1">value1</value> (use the name as an attribute)
  • <record><name>name1</name><value>value1</value></record> (make each pair of names and values child elements of a new element)

_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
aks
PostPosted: Tue Jan 13, 2004 6:32 pm    Post subject: Reply with quote

Voyager

Joined: 19 Jul 2002
Posts: 84

Thanks Jeff,
I will use the attribute way for elements with a single value.
I have some content that requires 2 values (eg, Name, then Item and ItemValue). In this case I will do the way you coded <record ...

Alan
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 statement help required for XML messages
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.