|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Select stement in XML (Attributes in Where Clause) |
« View previous topic :: View next topic » |
Author |
Message
|
Ramphart |
Posted: Mon Feb 11, 2013 4:46 pm Post subject: Select stement in XML (Attributes in Where Clause) |
|
|
 Disciple
Joined: 21 Jul 2004 Posts: 150 Location: South Africa, JHB
|
WebSphere Broker v7.0.0.5,
Windows Server 2008 R2 Standard
I need to use a Select statement to return the element field value based on it's attribute value:
Quote: |
<shipTo>
<tag TypeCode="CODE">abc</tag>
<tag TypeCode="PLANT">def</tag>
<tag TypeCode="YEAR">2013</tag>
</shipTo>
|
Code: |
SET OutputRoot.MRM.LineItems[cntLine].Plant = THE (SELECT FIELDVALUE(InputRoot.XMLNSC.shipTo.tag)
FROM InputRoot.XMLNSC.InputRoot.XMLNSC.shipTo.tag[]
WHERE FIELDVALUE(InputRoot.XMLNSC.InputRoot.XMLNSC.shipTo.tag.(XMLNSC.Attribute)TypeCode) = 'PLANT');
|
The expected result is that value "def" is returned. However, the code above return NULL. It works if I search for the first TypeCode="CODE" in the <tag> array though and returns "abc"
Can someone help me with the proper syntax to search for a tag field value further down in the <tag> array when interrogating the tree based on the corresponding TypeCode attribute?
Thanks in advance for your response _________________ Applications Architect |
|
Back to top |
|
 |
kash3338 |
Posted: Mon Feb 11, 2013 10:01 pm Post subject: |
|
|
Shaman
Joined: 08 Feb 2009 Posts: 709 Location: Chennai, India
|
This code should work,
Code: |
SET OutputRoot.XMLNSC.LineItems.Plant = THE (SELECT ITEM FIELDVALUE(T) FROM InputRoot.XMLNSC.shipTo.tag[] AS T WHERE FIELDVALUE(T.(XMLNSC.Attribute)TypeCode) = 'PLANT');
|
|
|
Back to top |
|
 |
Ramphart |
Posted: Mon Feb 11, 2013 11:31 pm Post subject: |
|
|
 Disciple
Joined: 21 Jul 2004 Posts: 150 Location: South Africa, JHB
|
Hi kash
It works like a charm. Thx a mil. _________________ Applications Architect |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Feb 12, 2013 4:27 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Ramphart wrote: |
Hi kash
It works like a charm. Thx a mil. |
You always have to use AS and a qualifier in ESQL Select, so you always have to say something like 'AS T' and then use 'T.' to reference the selected fields. |
|
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
|
|
|
|