WHY driver convert FLOAT POINT to FIX POINT?
-
- Posts: 4
- Joined: Tue 05 Apr 2011 10:11
WHY driver convert FLOAT POINT to FIX POINT?
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.
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.
hello,
To resolve the problem, you should set the EnableBCD option to false like:
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;
-
- Posts: 4
- Joined: Tue 05 Apr 2011 10:11
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:
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;
-
- Posts: 4
- Joined: Tue 05 Apr 2011 10:11
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.
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.
-
- Posts: 4
- Joined: Tue 05 Apr 2011 10:11
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.
Edit1.Text:=0.123456789012
Try this test.