WHY driver convert FLOAT POINT to FIX POINT?

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for Oracle in Delphi and C++Builder
Post Reply
a.n.ermakov
Posts: 4
Joined: Tue 05 Apr 2011 10:11

WHY driver convert FLOAT POINT to FIX POINT?

Post by a.n.ermakov » Tue 05 Apr 2011 10:41

I am using dbexpoda.dll 4.80( last version), Delphi 7, Oracle11g.

ORACLE fields with data type BINARY_DOUBLE (it is floating point type but not fixed point type) in DELPHI have class TFMTBCDField.

I think it is MISTAKE. Must be class TFLOATField! Else I miss the precission in calculation.

Thanks in advance.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Tue 05 Apr 2011 13:02

hello,

To resolve the problem, you should set the EnableBCD option to false like:

Code: Select all

procedure TForm1.SQLQuery1BeforeOpen(DataSet: TDataSet);
const
  coEnableBCD = TSQLConnectionOption(102); 
begin
  SQLConnection1.SQLConnection.SetOption(coEnableBCD, Integer(False));
end;

a.n.ermakov
Posts: 4
Joined: Tue 05 Apr 2011 10:11

Post by a.n.ermakov » Wed 06 Apr 2011 09:52

[quote="AlexP"]hello,

To resolve the problem, you should set the EnableBCD option to false like:

It is no decision of problem. Realy I need fixed and float point numbers in the same application.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Wed 06 Apr 2011 11:35

Hello,

You can have the fixed and float point numbers in the same application, but you can't have them in the same dataset.
To have this effect, you can set the EnableBCD option each time before opening DataSet, like:

Code: Select all

procedure TForm1.SQLQuery1BeforeOpen(DataSet: TDataSet);
const
  coEnableBCD = TSQLConnectionOption(102);
begin
  SQLConnection1.SQLConnection.SetOption(coEnableBCD, Integer(False)); //ftFloat
end;

procedure TForm1.SQLQuery2BeforeOpen(DataSet: TDataSet);
const
  coEnableBCD = TSQLConnectionOption(102);
begin
  SQLConnection1.SQLConnection.SetOption(coEnableBCD, Integer(True)); //ftFMTBcd
end;

a.n.ermakov
Posts: 4
Joined: Tue 05 Apr 2011 10:11

Post by a.n.ermakov » Thu 07 Apr 2011 10:12

I need to have the fixed and float point numbers in the same dataset.

Delphi read float pointing values in FMTBCD type with precision 32 and scale 8, and it cannot be changed.
We need 14 digits after point in some cases.
In MSSQL driver you solve this problem and use float type fields for float numbers and FMTBCD for fixed point numbers.
If we use driver option EnableBCD = false then we loose numbers more then 15 sign digits, and will have round errors.

a.n.ermakov
Posts: 4
Joined: Tue 05 Apr 2011 10:11

Post by a.n.ermakov » Thu 07 Apr 2011 10:21

Code: Select all

unit Unit1;

interface

uses
  Windows, FMTBcd, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Grids, DBGrids, DB, DBClient, SimpleDS, Mask, DBCtrls,
  DBXpress, SqlExpr;

type
  TForm1 = class(TForm)
    SimpleDataSet1: TSimpleDataSet;
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    Button1: TButton;
    Button2: TButton;
    DBEdit1: TDBEdit;
    SQLQuery1: TSQLQuery;
    SQLConnection1: TSQLConnection;
    Edit1: TEdit;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  SQLQuery1.Active:=false;
  SQLQuery1.Params[0].AsFMTBCD:=Strtobcd(Edit1.Text);
  SQLQuery1.ExecSQL;
end;

procedure TForm1.Button2Click(Sender: TObject);
var vtest:string;
begin
  SimpleDataSet1.Active:=false;
  SimpleDataSet1.Active:=true;
  vtest:=BcdToStr(SimpleDataSet1.FieldByName('A').AsBCD);
  ShowMessage(vtest);
end;

end.
Field type 'A' in Oracle BINARY_DOUBLE

Edit1.Text:=0.123456789012

Try this test.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Mon 11 Apr 2011 08:58

Hello,

We have fixed the problem.
This fix will be included in the next build.
To make sure that everything works correctly, we can send you the new trial version for testing before it will be released.
Please specify your e-mail address, so that I could send you the fixed trial version.

Post Reply