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 sum

Post new topic  Reply to topic
 Select sum « View previous topic :: View next topic » 
Author Message
rasol
PostPosted: Wed Aug 16, 2006 12:52 pm    Post subject: Select sum Reply with quote

Novice

Joined: 08 Aug 2006
Posts: 14

Hi All,

I want to acculmate the amount of each item from a XML message.

Here is the code and it works fine

[code]
WHILE (Count <= Environment.Variables.TotalRecords) DO
SET Environment.Variables.Amount = CAST(InputRoot.MRM.ns:cob_details.details:cob_details[Count].details:AMOUNT AS DECIMAL);
SET Totalsum = Totalsum + Environment.Variables.Amount;
SET Count = Count + 1;
END WHILE;
[/code]

but for efficiency, I used SELECT SUM and nothin is return. I cannot see Environment.Variables.Total in debug mode.

[code]
SET Environment.Variables.Total = (SELECT SUM(CAST(I.AMOUNT AS DECIMAL)) FROM InputRoot.MRM.ns:cob_details.*[] AS I);
[/code]

Any suggestion
Back to top
View user's profile Send private message
JT
PostPosted: Wed Aug 16, 2006 2:45 pm    Post subject: Reply with quote

Padawan

Joined: 27 Mar 2003
Posts: 1564
Location: Hartford, CT.

Have you seen this thread ?
http://www.mqseries.net/phpBB2/viewtopic.php?t=17056
Back to top
View user's profile Send private message
rasol
PostPosted: Wed Aug 16, 2006 3:52 pm    Post subject: Reply with quote

Novice

Joined: 08 Aug 2006
Posts: 14

I looked into that thread and I coded the same but I cannot see Environment.Variables.Total field after the execution of SELECT statement in debug mode.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Aug 16, 2006 3:58 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

How do you handle one of the values being null?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
rasol
PostPosted: Wed Aug 16, 2006 4:01 pm    Post subject: Reply with quote

Novice

Joined: 08 Aug 2006
Posts: 14

none of the values are null.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Aug 16, 2006 4:06 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

rasol wrote:
none of the values are null.

You mean to say that none of the CASTS (I.AMOUNT to decimal) will ever return a null value? How can you garantee this? You might want to use coalesce...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
rasol
PostPosted: Wed Aug 16, 2006 10:17 pm    Post subject: Reply with quote

Novice

Joined: 08 Aug 2006
Posts: 14

The message comes from SAP system and we have handled AMOUNT field upfront in SAP system .So AMOUNT will not have null values when it comes to WBI.

All I have to do is to accumulate the sum of all the occurance from a XML message.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Aug 17, 2006 2:40 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

rasol wrote:
The message comes from SAP system and we have handled AMOUNT field upfront in SAP system .So AMOUNT will not have null values when it comes to WBI.
I would not trust the last part of this statement that much. The question is could you ever have spaces instead of a numeric value? And if you always have a numeric value could there be instances where your CAST as DECIMAL would produce a null value?

The return from your select seems to be familiar with at least one of the result values being null which would make the result be null.

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Select sum
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.