I'm trying to insert a record in a table with a numeric(18,7) field. For some values on this field, everything goes fine, but there are some values which show an issue regarding precision. For exemple: 2.16. When I try to store this value on that field, the actual stored value is 2.1600001.
I managed to reproduce it this way:
Code: Select all
uses
ZDbcIntfs, ZDbcInterbase6;
procedure TForm1.Button1Click(Sender: TObject);
var
Stmt: IZPreparedStatement;
RS: IZResultSet;
Con: IZConnection;
begin
Con := DriverManager.GetConnection('Put here your connection string to a FB 2.0 database');
Stmt := Con.PrepareStatement('insert into test_table(test_field) values (?)');
Stmt.SetFloat(1, 2.16);
Stmt.ExecuteUpdatePrepared;
RS := Con.CreateStatement.ExecuteQuery('select test_field from test_table');
RS.Next;
ShowMessage(RS.GetString(1));
end;
Unfortunatelly I can't look to another way to put the value on the prepared statement because in my real case I'm not acessing the prepared statement directly, instead i'm using data aware controls and clientdataset linked to a tzreadonlyfield, so all the prepared statement stuff happens behind the scenes.