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 » Decimal value

Post new topic  Reply to topic Goto page 1, 2  Next
 Decimal value « View previous topic :: View next topic » 
Author Message
ydeonia
PostPosted: Wed Feb 27, 2013 7:58 pm    Post subject: Decimal value Reply with quote

Acolyte

Joined: 29 Oct 2012
Posts: 74

Hi

How can I chekc if the value is decimal of not . If it has two sequence decimal I need to remove it .

like if I have the value 111111.34 First I need to check if it has decimal of not . If yes then I need to remove '.' and output should be 11111134 .

How can I check for decimal value?
Back to top
View user's profile Send private message
ydeonia
PostPosted: Wed Feb 27, 2013 11:17 pm    Post subject: Reply with quote

Acolyte

Joined: 29 Oct 2012
Posts: 74

Anybody please ..

How can I check for decimal values?
Back to top
View user's profile Send private message
rekarm01
PostPosted: Thu Feb 28, 2013 12:48 am    Post subject: Re: Decimal value Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

ydeonia wrote:
How can I check for decimal values?

What does that mean, "check for decimal values"? DECIMAL is a data type. If the question is how to remove the fractional part of a decimal number, the TRUNCATE function may be useful.
Back to top
View user's profile Send private message
nathanw
PostPosted: Thu Feb 28, 2013 1:13 am    Post subject: Reply with quote

Knight

Joined: 14 Jul 2004
Posts: 550

If there is always 2 decimal places then you can check from thr right hand start point and count the chars and then remove the . so that the number becomes non decimal as you have suggested

alternatively for any field which will contain a decimal number then simply run a replace . with NULL or '' on that particular field.

although I am not sure why when you have a valid value ie 1234.56 you would want to only have 123456
_________________
Who is General Failure and why is he reading my hard drive?

Artificial Intelligence stands no chance against Natural Stupidity.

Only the User Trace Speaks The Truth
Back to top
View user's profile Send private message MSN Messenger
ydeonia
PostPosted: Thu Feb 28, 2013 1:28 am    Post subject: Reply with quote

Acolyte

Joined: 29 Oct 2012
Posts: 74

Requirement is like

Price for AB to shop
[Change]
Current (Decimal): 999999(.)99
New (Integer): 99999999



I am stucked to remove the decimal .
Back to top
View user's profile Send private message
nathanw
PostPosted: Thu Feb 28, 2013 1:34 am    Post subject: Reply with quote

Knight

Joined: 14 Jul 2004
Posts: 550

if you follow my comment earlier i have pointed you to 2 methods

read up on ESQL and the processes involved
_________________
Who is General Failure and why is he reading my hard drive?

Artificial Intelligence stands no chance against Natural Stupidity.

Only the User Trace Speaks The Truth
Back to top
View user's profile Send private message MSN Messenger
adubya
PostPosted: Thu Feb 28, 2013 1:50 am    Post subject: Reply with quote

Partisan

Joined: 25 Aug 2011
Posts: 377
Location: GU12, UK

Multiply by 100.

Back to top
View user's profile Send private message Send e-mail
ydeonia
PostPosted: Thu Feb 28, 2013 8:00 pm    Post subject: Reply with quote

Acolyte

Joined: 29 Oct 2012
Posts: 74

adubya wrote:
Multiply by 100.



Thanks I have tried this before but the problem is like the data can be without decimal . then I * 100 is not good option .

I just want to check the decimal value first then I can handle on situation .Is there is any way to check the decimal is present in data or not ?

@nathanw
I tried (here is always 2 decimal places) The data can be non decimal too. But yes when it will be there it will be 2 decimal precision.

for NULL

Do you mean to say like
Code:
SET outref."ABSO_COL23_O"  = REPLACE(inref."ABSO_COL23_I" ,'.',NULL);


I tried it fails .
any other suggestion please
Back to top
View user's profile Send private message
rekarm01
PostPosted: Fri Mar 01, 2013 1:06 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

ydeonia wrote:
Code:
SET outref."ABSO_COL23_O"  = REPLACE(inref."ABSO_COL23_I" ,'.',NULL);

The double-quotes are not necessary here.

ydeonia wrote:
I tried it fails .

How does it fail? If there's an error message, it might be useful to share that.

REPLACE() works with strings, not decimals. Perhaps a CAST or two to convert the data back and forth would help.
Back to top
View user's profile Send private message
nathanw
PostPosted: Fri Mar 01, 2013 1:10 am    Post subject: Reply with quote

Knight

Joined: 14 Jul 2004
Posts: 550

as rekarm says you may need to cast

have a look at your code and try the different ways

you are on the right track just keep going
_________________
Who is General Failure and why is he reading my hard drive?

Artificial Intelligence stands no chance against Natural Stupidity.

Only the User Trace Speaks The Truth
Back to top
View user's profile Send private message MSN Messenger
sandy vish
PostPosted: Fri Mar 01, 2013 2:31 am    Post subject: Reply with quote

Apprentice

Joined: 18 Nov 2012
Posts: 27

This might help
Quote:
DECLARE vDecimal DECIMAL 9999999.99;
DECLARE decimalCast CHARACTER CAST(vDecimal AS CHARACTER);
IF(CONTAINS(decimalCast , '.')) THEN
SET decimalCast = REPLACE(decimalCast,'.','');
END IF;
SET vDecimal = CAST(decimalCast AS DECIMAL);
Back to top
View user's profile Send private message
kimbert
PostPosted: Fri Mar 01, 2013 2:58 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
if I have the value 111111.34 First I need to check if it has decimal of not . If yes then I need to remove '.' and output should be 11111134
I have an important question; What is your message flow trying to do?
WMB has built-in functionality for doing this sort of thing. So you may be struggling to implement this using ESQL when the CWF or TDS parser could do it automatically.
Back to top
View user's profile Send private message
vmcgloin
PostPosted: Fri Mar 01, 2013 6:21 am    Post subject: Reply with quote

Knight

Joined: 04 Apr 2002
Posts: 560
Location: Scotland

I have not thought this through fully or checked my logic, but could you achieve what you want by checking that

(FLOOR(n) is not equal to n) AND (n - FLOOR(n) is not equal to 0) ?

The second part is to avoid .00 but it would be much much better to specify the denomination in the incoming data to avoid catastophic pricing errors when multiplying by 100.
Back to top
View user's profile Send private message
nathanw
PostPosted: Fri Mar 01, 2013 7:10 am    Post subject: Reply with quote

Knight

Joined: 14 Jul 2004
Posts: 550

as the incoming data is never always .00 then simply multiplying by 100 is not acceptable

a simple replace of . is the easiest and simplest method as it it is not there then there is no need to replace etc etc
_________________
Who is General Failure and why is he reading my hard drive?

Artificial Intelligence stands no chance against Natural Stupidity.

Only the User Trace Speaks The Truth
Back to top
View user's profile Send private message MSN Messenger
mqjeff
PostPosted: Fri Mar 01, 2013 7:30 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

nathanw wrote:
as the incoming data is never always .00 then simply multiplying by 100 is not acceptable


The only difficulty with multiplying by 100 is that the number might have more than two significant digits after the decimal.

If it is determined that the business logic does not find any meaningful value in any number that is three significant digits or more after the decimal, then there's nothing wrong with multipling by 100 and casting to an integer.



nathanw wrote:
a simple replace of . is the easiest and simplest method as it it is not there then there is no need to replace etc etc

If the intent is to remove all significant digits after the decimal, I would cast to a string and then SUBSTRING BEFORE the decimal, and then if I had to cast back to an INT.

If the intent is to remove all significant digits after the 2nd significant digits after the decimal, I would multiply by 100, cast to a string, and then SUBSTRING BEFORE.

If the intent is to accurately deal with a value that may or may not have significant digits after the decimal point and limit that value to a specific precision, I would do the correct thing and ensure that the physical parser I am working with - CWF, TDS, DFDL, was configured to understand the limitations and enforce them.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

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