db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel John Debrunner <...@debrunners.com>
Subject Re: Problem with decimal precision
Date Fri, 04 Mar 2005 14:28:15 GMT
fabio_patricio wrote:
>   Hi,
> 
>   I have a field decimal(10,2) where I insert "32,78", but when I go
> to look at in the table the inserted value was "32,77", alguem which
> the problem?
> 

This is a bug Derby-123 and is fixed in the development trunk.

http://issues.apache.org/jira/browse/DERBY-123

Though as Jeff said, using doubles and DECIMAL may lead to unexpected
results due to mixing of imprecise and precise values.


>   My code:

>             pstmt.setDouble(1, new Double("32.78").doubleValue());

You can also use setString() on most types in Derby, thus the above line
could have been

pstmt.setString(1, "32.78");

That will insert the correct value in Derby's current release 10.0.2.1

Dan.


Mime
View raw message