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 » Grouping and adding in ESQL.

Post new topic  Reply to topic
 Grouping and adding in ESQL. « View previous topic :: View next topic » 
Author Message
nukalas2010
PostPosted: Mon Aug 22, 2011 10:23 pm    Post subject: Grouping and adding in ESQL. Reply with quote

Master

Joined: 04 Oct 2010
Posts: 220
Location: Somewhere in the World....

Hi All,
I have a message that has a tag as follows:
Code:
<x:Summary>
  <x:xAmount>1905210</x:xAmount>
  <x:xCurrency>USD</x:xCurrency>
  <x:xAmount>500745.46</x:xAmount>
  <x:xCurrency>USD</x:xCurrency>
  <x:xAmount>27486.09</x:xAmount>
  <x:xCurrency>EUR</x:xCurrency>
  <x:yAmount>330000</x:yAmount>
  <x:yCurrency>USD</x:yCurrency>
  <x:yAmount>100000</x:yAmount>
  <x:yCurrency>USD</x:yCurrency>
  <x:yAmount>9000</x:yAmount>
  <x:yCurrency>USD</x:yCurrency>
  <x:yAmount>1000</x:yAmount>
  <x:yCurrency>EUR</x:yCurrency>
  <x:yAmount>21010000</x:yAmount>
  <x:yCurrency>EUR</x:yCurrency>
  <x:yAmount>10000</x:yAmount>
  <x:yCurrency>EUR</x:yCurrency>
  <x:yAmount>110000</x:yAmount>
  <x:yCurrency>EUR</x:yCurrency>
  <x:yAmount>1000</x:yAmount>
  <x:yCurrency>EUR</x:yCurrency>
</x:Summary>


Now, i have to find all the amount corresponding to the respective currency, and add them up so that my final result would have only one amount and currency.
For eg:
my final output should have
Code:
<x:xAmount>sum of all xAmounts</x:Amount> and <x:xCurrency>USD</x:Currency>
<x:yAmount>sum of all yAmounts</y:Amount> and
<x:yCurrency>EUR</y:Currency>


Please give me logic to achieve this using esql.
I am not familiar with java compute node to do this using java.

Any help is greately appreciated.

Thanks!!!
Back to top
View user's profile Send private message
WGerstma
PostPosted: Tue Aug 23, 2011 12:37 am    Post subject: Reply with quote

Acolyte

Joined: 18 Jul 2011
Posts: 55

Rather easy using the {}

Something like
Code:

SET Environment.{InputRoot.MRM.xCurrency} = COALSECE(InputRoot.MRM.xAmount, 0) + Environment.{InputRoot.MRM.xCurrency}

From the Environment you can easily trasnform to the wished OutputRootFormat
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Aug 23, 2011 5:49 am    Post subject: Reply with quote

Grand High Poobah

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

WGerstma wrote:
Something like
Code:

SET Environment.{InputRoot.MRM.xCurrency} = COALSECE(InputRoot.MRM.xAmount, 0) + Environment.{InputRoot.MRM.xCurrency}


Though of course you'd not use MRM to parse namespaced XML...
_________________
Honesty is the best policy.
Insanity is the best defence.
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 » Grouping and adding in ESQL.
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.