oracle-databasedelphiodbcbde

TQuery Float field is implicitly rounded to integer when using ODBC


I'm querying 1 value from table. In db it's value is 48.8

When my app use BDE's native Oracle SQL Link driver, everything is Ok, it's still 48.8.

Then I make the app to use another BDE alias, which use ODBC data source (latest driver from Oracle). And now displayed value is 48.0


Details

The column is factW NUMBER(10, 3).

Test code:

var
  q: TQuery;
begin
  q := TQuery.Create( SELF );
  try
    q.DatabaseName := 'Realize';
    q.SQL.Text := 'SELECT factW, TO_CHAR(factW) charW'
                 +'FROM bSertific WHERE id_sertific = :id';
    q.ParamByName('id').AsInteger := dm1.Sertif1ID_SERTIFIC.AsInteger;
    q.Open;

    ShowMessage( ' factW = ' 
                 + FloatToStrF( 
                        q.FieldByName('factW').AsFloat, 
                        ffFixed, 
                        5, 3 )                                   // here 48.000
                 + ' charW = ' + q.FieldByName('charW').AsString // here 48.8
    );
  finally
    q.Free;
  end;
end;

Solution

  • I hadn't find a proper solution. The workaround is to query the field as a string and convert it back and forth on the client side.