db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel John Debrunner <...@apache.org>
Subject Re: DerbyDB truncates the values inserted in a numeric field instead of approximating them
Date Fri, 03 Feb 2006 15:25:22 GMT
Jacopo Cappellato wrote:
> Daniel, Dag,
> 
> thanks for your answers: they are really helpful.
> 
> Well, right now we are now using NUMERIC(18,2) field types for currency
> amount fields... so that values are stored in the db with the exact
> number of decimal we need (0k, we are actually in the process of
> reviewing this approach).
> 
> Do you think we should use a different field type? (e.g. DECIMAL)

DECIMAL and NUMERIC are the same in Derby. So it looks like you are
using the correct type. One option is to increase the scale of the
number (digits after the decimal point), e.g. NUMERIC(20,4) which would
then hold two extra digits that would be lost in the assignment to
NUMERIC(18.2). Maybe this is what you meant by approximation, the
ability to control the rounding as Dag said?

Dan.

[
The SQL standard allows DECIMAL (I think) to have greater precision than
defined while NUMERIC must match its defined precision.
]





Mime
View raw message