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 » Retrieving decimal values in message broker

Post new topic  Reply to topic
 Retrieving decimal values in message broker « View previous topic :: View next topic » 
Author Message
Muthukrishnan
PostPosted: Tue Jun 18, 2013 11:01 pm    Post subject: Retrieving decimal values in message broker Reply with quote

Apprentice

Joined: 16 Feb 2013
Posts: 48

Hi,

Below is my requirement. Can anyone please help to get the output for all the possible combinations of the input below.

Code:


Input - 22.50
Output-22.5

Input - 50.00
Output - 50

Input - 77.70
Output - 77.7

Input - 16.50
Output - 16.5



Back to top
View user's profile Send private message Send e-mail
kimbert
PostPosted: Wed Jun 19, 2013 2:43 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

So the rules seem to be:
- For fractional numbers, write the value with one digit after the decimal point
- for integer numbers, write the value with no decimal point
Is that corrrect?

You need to tell us
a) the rounding rules are ( what output do you want for 22.54, 22.55 and 22.56? ).
b) what the output format is ( XML / DFDL etc )
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Wed Jun 19, 2013 3:13 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

kimbert wrote:
You need to tell us
a) the rounding rules are ( what output do you want for 22.54, 22.55 and 22.56? ).
b) what the output format is ( XML / DFDL etc )


Also would be helpful for the OP to tell us what s/he has tried, and what the results were.
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
Muthukrishnan
PostPosted: Wed Jun 19, 2013 4:19 am    Post subject: Reply with quote

Apprentice

Joined: 16 Feb 2013
Posts: 48

Quote:


If the input is 22.55 then output also should be 22.55. Also the input and output are XML. I am trying couple of things. But not getting a concrete code to post as I am new to esql.
Back to top
View user's profile Send private message Send e-mail
kimbert
PostPosted: Wed Jun 19, 2013 4:52 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Ah! So the requirement is to remove trailing zeros without changing the value of the decimal. That makes it very easy.

1. Create or obtain an XSD that describes your input XML
2. Deploy the XSD along with the message flow. How you do that will depend on which version you are using, but it's all described in the info center.
3. On the input node, set Validation to 'Content and Value' and tick the box that says 'Build tree using XML Schema types'.
4. The message tree will now contain decimal values instead of strings. When the XMLNSC parser outputs the message tree as XML, there will be no trailing zeros.


Last edited by kimbert on Wed Jun 19, 2013 6:07 am; edited 1 time in total
Back to top
View user's profile Send private message
vmcgloin
PostPosted: Wed Jun 19, 2013 4:59 am    Post subject: Reply with quote

Knight

Joined: 04 Apr 2002
Posts: 560
Location: Scotland

Make use of the infocentre if you aren't already.

Maybe try cast with a format of 00.## or post exactly what you are trying and the results you get.

Edited to add: sorry - i did not see the previous response. I didn't mean to cause offence and I come from a land where fully message xsd's are rare
Back to top
View user's profile Send private message
Muthukrishnan
PostPosted: Wed Jun 19, 2013 6:41 pm    Post subject: Retrieving decimal values in message broker Reply with quote

Apprentice

Joined: 16 Feb 2013
Posts: 48

Dear all,

Thanks for your suggestions. Let me try them. But I am afraid I wont be having xsd. I would like to handle them in esql. Is there any way to remove only the trailing zeros and not to disturb the decimals values if present in the input ?
Back to top
View user's profile Send private message Send e-mail
fjb_saper
PostPosted: Wed Jun 19, 2013 8:53 pm    Post subject: Reply with quote

Grand High Poobah

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

You can try and cast your numbers to a decimal type?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
AkankshA
PostPosted: Wed Jun 19, 2013 10:30 pm    Post subject: Reply with quote

Grand Master

Joined: 12 Jan 2006
Posts: 1494
Location: Singapore

the dirty method to do would be to take the number after the decimal, trim the '0' of the right side and then concat it back...

but like i said, its a dirty method and shall be your last option
_________________
Cheers
Back to top
View user's profile Send private message Visit poster's website
kimbert
PostPosted: Thu Jun 20, 2013 5:21 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
Is there any way to remove only the trailing zeros and not to disturb the decimals values if present in the input ?
Yes - use ESQL CAST to do what the XML parser would have done
- convert the string to a logical decimal value
- convert the decimal value back to a string

The CAST function is very well documented, so please excuse me if I leave the details up to you.
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 » Retrieving decimal values in message broker
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.