Subject Re: Numeric Rounding Error
Author liglezias2
The problem is with BDE, IBX, etc... They interpret any float
parameter as if it realy is a float number... When writing to
parameter "1.3", probably the number they will pass to the sql
Server is "1.2999999". And this is not a numeric(12,2) value :-(

In Sybase database, I solved it (using BDE) editing de Insert and
Update SQL's of TUpdateObject, like this:

"insert into xxx (pK, FloatField) values (:pk, round(:FF,2) )"

Parameter FF will have 1.29999 yet... but now the DB could accept
the value :-)

try using a solution like that, using a FB function (may be UDF)
that accepts a float and returns a numeric(x,y)..
or change this field to float or double.

Lucio I.P.


--- In firebird-support@yahoogroups.com, Greg Kay <gkay@o...> wrote:
> Hi,
>
> We have an intermittent problem with a NUMERIC(12,2) field
occasionally
> being incorrectly rounded. We are doing simple inserts like
>
> "INSERT INTO MyTable (ID, F1, F2) Values(:ID, :F1, :F2)" with
params
> ID='IT02138733', F1=37732.67, F2=0
>
> but the value in F1 is rounded to 37733 in the database. ID is CHAR
(10)
> and F1 and F2 are NUMERIC(12,2). This is not happening all the
time and
> cannot be routinely reproduced. We do probably a few hundred of
these
> inserts per day but only about 3 have this rounding error.
>
> We're using Delphi with IBX and Firebird 1.02.
>
> Greg