Hi all,
I´m having rounding issues with Zeos and Firebird.
When i set a parameter to 3.26, it stores 3.2599 in the database.
I´m using "PreparedStatement.SetValue(n, DecodeVariant(Value))".
Does someone have these kind of issues? Is it related to Firebird or to Zeos?
I noticed that all Zeos methods used to assign numeric parameter values works with floating point types, including SetBigDecimal, which was supposed to use a decimal type (probably a TBCD in Delphi), so it seems we can have a design problem here.
Is there someone aware of a workaround for my case?
Regards,
Fabiano
Rounding issues
Moderators: gto, EgonHugeist
-
- Fresh Boarder
- Posts: 15
- Joined: 13.02.2009, 18:55
- Location: Americana/SP
This issue is known and correct
So download lastest svn version or check if version you are using is patched
So download lastest svn version or check if version you are using is patched
-
- Fresh Boarder
- Posts: 15
- Joined: 13.02.2009, 18:55
- Location: Americana/SP
Hi, Seawolf
I´m afraid there is still something wrong there.
I downloaded the patch from mdaems, recompiled, and 1 of the tests below still writes wrong data to the database
Test1 stores the right value in the database
Test2 stores 3.259999...
It seems the patch treats just field retrieval, not parameters updates.
FIREBIRD: CREATE TABLE T (F NUMERIC(13,4));
uses
ZDbcInterbase6, ZDbcIntfs, ZVariant;
procedure TForm5.Button1Click(Sender: TObject);
var
C: IZConnection;
P: IZPreparedStatement;
Value: Extended;
begin
Value := 3.26;
C := DriverManager.GetConnection('zdbc:firebird-2.0://127.0.0.1/tecelagem?UID=sysdba;PWD=masterkey');
C.Open;
// Test1 - WRITES 3.26
P := C.PrepareStatement('insert into t values (?)');
P.SetBigDecimal(1, Value);
P.ExecutePrepared;
// Test2 - WRITES 3.2599
P := C.PrepareStatement('insert into t values (?)');
P.SetValue(1, DecodeVariant(Value));
P.ExecutePrepared;
end;
I´m afraid there is still something wrong there.
I downloaded the patch from mdaems, recompiled, and 1 of the tests below still writes wrong data to the database
Test1 stores the right value in the database
Test2 stores 3.259999...
It seems the patch treats just field retrieval, not parameters updates.
FIREBIRD: CREATE TABLE T (F NUMERIC(13,4));
uses
ZDbcInterbase6, ZDbcIntfs, ZVariant;
procedure TForm5.Button1Click(Sender: TObject);
var
C: IZConnection;
P: IZPreparedStatement;
Value: Extended;
begin
Value := 3.26;
C := DriverManager.GetConnection('zdbc:firebird-2.0://127.0.0.1/tecelagem?UID=sysdba;PWD=masterkey');
C.Open;
// Test1 - WRITES 3.26
P := C.PrepareStatement('insert into t values (?)');
P.SetBigDecimal(1, Value);
P.ExecutePrepared;
// Test2 - WRITES 3.2599
P := C.PrepareStatement('insert into t values (?)');
P.SetValue(1, DecodeVariant(Value));
P.ExecutePrepared;
end;