Author |
Message
|
gabbar |
Posted: Wed Feb 04, 2004 8:02 am Post subject: Selecting a MAX value |
|
|
Acolyte
Joined: 10 Dec 2002 Posts: 50
|
Can anyone suggest the simplest ESQL expression of selecting a MAX value from a repeating group of elements.
In my XML, i have an element which may occur more than once in the same message, as in the following example:
<TESTXML>
<TESTGRP>
<MYVALUE>20</MYVALUE>
</TESTGRP>
<TESTGRP>
<MYVALUE>30</MYVALUE>
</TESTGRP>
</TESTXML>
I am supposed to select the max(MYVALUE) from the incoming XML. I hope the SELECT with MAX call will help do this.
Can anyone help?
Thanks |
|
Back to top |
|
 |
kirani |
Posted: Wed Feb 04, 2004 10:38 am Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
Try this,
Code: |
SET Environment.Variables.MYMAXVALUE = THE (SELECT ITEM MAX(t.MYVALUE) from InputRoot.XML.TESTXML.TESTGRP[] as t)
|
_________________ Kiran
IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries
|
|
Back to top |
|
 |
gabbar |
Posted: Wed Feb 04, 2004 10:57 am Post subject: |
|
|
Acolyte
Joined: 10 Dec 2002 Posts: 50
|
I am on wmqi 2.1 csd03. Does MAX work for me? Compute Node doesn't like the Syntax.
Quote: |
SET Environment.Variables.MYMAXVALUE = THE (SELECT ITEM MAX(t.MYVALUE) from InputRoot.XML.TESTXML.TESTGRP[] as t); |
|
|
Back to top |
|
 |
kirani |
Posted: Wed Feb 04, 2004 11:17 am Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
Are you getting a Deploy Error or it's just a syntax error in the Control center? If it's a syntax error, then ignore it and try doing a deploy. _________________ Kiran
IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries
|
|
Back to top |
|
 |
gabbar |
Posted: Wed Feb 04, 2004 11:26 am Post subject: |
|
|
Acolyte
Joined: 10 Dec 2002 Posts: 50
|
Like you said I deployed despite the syntax error. This is what I see when I deploy.
Quote: |
BIP2938E: An attempt was made to execute the non existent function or procedure 'MAX'. |
|
|
Back to top |
|
 |
kirani |
Posted: Wed Feb 04, 2004 12:06 pm Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
I tried this code on my machine and it's working correctly. I am at CSD4, but I don't think its an issue, MAX column function is supported by ESQL.
Code: |
SET Environment.Variables.MYMAXVALUE = THE (SELECT MAX(t.MYVALUE) from InputRoot.XML.TESTXML.TESTGRP[] as t);
|
As you can see in my code, I removed ITEM clause. _________________ Kiran
IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries
|
|
Back to top |
|
 |
gabbar |
Posted: Wed Feb 04, 2004 12:23 pm Post subject: |
|
|
Acolyte
Joined: 10 Dec 2002 Posts: 50
|
Strange as it is, removing the ITEM keyword makes the broker now recognize the MAX function.
It works!!
Thanks Kiran |
|
Back to top |
|
 |
|