Use BCDField problem
Use BCDField problem
Hello,
I am using DbxOda version 4.50.20 now,but it always map Oracle number type to TFMTBCDField. I really want TBCDField.How can I fix it?
thanks,
wenli
I am using DbxOda version 4.50.20 now,but it always map Oracle number type to TFMTBCDField. I really want TBCDField.How can I fix it?
thanks,
wenli
Hello
The field data type depends on field precision in the database. If field precision in the database is more then the Delphi constant MaxBcdPrecision in the FMTBcd unit then the field will have the fldFmtBCD data type, otherwise the field will have the fldBCD data type. The NUMBER data type has precision 38 and it is more then the MaxBcdPrecision constant value. Unfortunately we cannot change the behavior of the Delphi classes and we cannot change the values of the Delphi constants.
The field data type depends on field precision in the database. If field precision in the database is more then the Delphi constant MaxBcdPrecision in the FMTBcd unit then the field will have the fldFmtBCD data type, otherwise the field will have the fldBCD data type. The NUMBER data type has precision 38 and it is more then the MaxBcdPrecision constant value. Unfortunately we cannot change the behavior of the Delphi classes and we cannot change the values of the Delphi constants.
hi,
This is my table schema:
create table ST_SYS_FUNCTION
(
FNCODE VARCHAR2(10) not null,
FNNAME VARCHAR2(30) not null,
FNMODULE VARCHAR2(30) not null,
FNMEMO VARCHAR2(255),
FNCLASSNAME VARCHAR2(100),
FNPOSITION NUMBER(2),
FNICON VARCHAR2(50),
FNSEPERATE CHAR(1) default 'N'
)
the FNPOSITION NUMBER(2) column always map to FMTBcd .
Thanks
This is my table schema:
create table ST_SYS_FUNCTION
(
FNCODE VARCHAR2(10) not null,
FNNAME VARCHAR2(30) not null,
FNMODULE VARCHAR2(30) not null,
FNMEMO VARCHAR2(255),
FNCLASSNAME VARCHAR2(100),
FNPOSITION NUMBER(2),
FNICON VARCHAR2(50),
FNSEPERATE CHAR(1) default 'N'
)
the FNPOSITION NUMBER(2) column always map to FMTBcd .
Thanks
Hi
I created a table:
I put to the form the following components: TSQLConnection, TSQLQuery, TDataSetProvider, TClientDataSet. In TSQLConnection I selected driver "Devart Oracle". To the TSQLQuery component I put the following query: "select * from ST_SYS_FUNCTION". And I executed the following code:
For the FNPOSITION field I see the TBCDField field type.
Try to delete all fields from the fields editor from from the TSQLQuery and TClientDataSet components and execute the code as stated above.
I created a table:
Code: Select all
create table ST_SYS_FUNCTION
(
FNCODE VARCHAR2(10) not null,
FNNAME VARCHAR2(30) not null,
FNMODULE VARCHAR2(30) not null,
FNMEMO VARCHAR2(255),
FNCLASSNAME VARCHAR2(100),
FNPOSITION NUMBER(2),
FNICON VARCHAR2(50),
FNSEPERATE CHAR(1) default 'N'
)
Code: Select all
var
i: integer;
begin
SQLQuery1.Open;
ClientDataSet1.Open;
for i := 0 to ClientDataSet1.FieldCount - 1 do
ShowMessage(ClientDataSet1.Fields[i].FieldName + ' - ' + ClientDataSet1.Fields[i].ClassName + #13 +
'DataType: ' + GetEnumName(TypeInfo(TFieldType), Integer(ClientDataSet1.Fields[i].Datatype)));
end;
Try to delete all fields from the fields editor from from the TSQLQuery and TClientDataSet components and execute the code as stated above.
The Oracle server 11 version has a problem: if you create a table as
create table ST_SYS_FUNCTION
then the Oracle server will return precision 2 for the FNPOSITION field for all queries.
But if you create a table as:
and later add a column as
then the Oracle server will return precision 38 for the FNPOSITION field for all queries.
Previous Oracle versions return correct precision in this case.
You can find discussion about this problem here: http://www.devart.com/forums/viewtopic.php?t=17432
create table ST_SYS_FUNCTION
Code: Select all
(
FNCODE VARCHAR2(10) not null,
FNNAME VARCHAR2(30) not null,
FNMODULE VARCHAR2(30) not null,
FNMEMO VARCHAR2(255),
FNCLASSNAME VARCHAR2(100),
FNPOSITION NUMBER(2),
FNICON VARCHAR2(50),
FNSEPERATE CHAR(1) default 'N'
)
But if you create a table as:
Code: Select all
create table ST_SYS_FUNCTION
(
FNCODE VARCHAR2(10) not null,
FNNAME VARCHAR2(30) not null,
FNMODULE VARCHAR2(30) not null,
FNMEMO VARCHAR2(255),
FNCLASSNAME VARCHAR2(100)
)
Code: Select all
alter table ST_SYS_FUNCTION
add FNPOSITION NUMBER(2)
Previous Oracle versions return correct precision in this case.
You can find discussion about this problem here: http://www.devart.com/forums/viewtopic.php?t=17432
Hello
Problem is that the DataTypeMap Delphi data type is responsible for equivalence between database data types and Delphi data types.
In the Delphi 7 this type declared as:
Data type with the BCD data type (code will be mapped to the ftBCD Delphi data type.
But in the Delphi 2007 the ftBCD data type is removed at all:
Data type with the BCD data type (code and with the FMTBCD data type (code 25) both will be mapped to the ftFMTBCD Delphi data type.
In the Delphi 2009 the ftBCD Delphi data type was returned but it has invalid index:
You can find this declaration in the “SqlExpr.pas” file in each Delphi version. If try to use native dbExpress driver for Oracle then you find same behavior: it will return ftFMTBCD data type for the column in the Delphi 2009 because of the DataTypeMap data type declaration.
So if you want to get ftBCD Delphi data type for your field then you should ask Embarcadero (owner of Delphi) to restore declaration of the DataTypeMap data type.
Problem is that the DataTypeMap Delphi data type is responsible for equivalence between database data types and Delphi data types.
In the Delphi 7 this type declared as:
Code: Select all
DataTypeMap: array[0..MAXLOGFLDTYPES - 1] of TFieldType = (
ftUnknown, ftString, ftDate, ftBlob, ftBoolean, ftSmallint,
ftInteger, ftFloat, ftBCD, ftBytes, ftTime, ftDateTime,
ftWord, ftInteger, ftUnknown, ftVarBytes, ftUnknown, ftCursor,
ftLargeInt, ftLargeInt, ftADT, ftArray, ftReference, ftDataSet,
ftTimeStamp, ftFMTBCD);
But in the Delphi 2007 the ftBCD data type is removed at all:
Code: Select all
DataTypeMap: array[0..TDBXDataTypes.MaxBaseTypes - 1] of TFieldType = (
ftUnknown, ftString, ftDate, ftBlob, ftBoolean, ftSmallint,
ftInteger, ftFloat, ftFMTBCD, ftBytes, ftTime, ftDateTime,
ftWord, ftInteger, ftUnknown, ftVarBytes, ftUnknown, ftCursor,
ftLargeInt, ftLargeInt, ftADT, ftArray, ftReference, ftDataSet,
ftTimeStamp, ftFMTBCD, ftWideString);
In the Delphi 2009 the ftBCD Delphi data type was returned but it has invalid index:
Code: Select all
DataTypeMap: array[0..TDBXDataTypes.MaxBaseTypes - 1] of TFieldType = (
ftUnknown, ftString, ftDate, ftBlob, ftBoolean, ftSmallint,
ftInteger, ftFloat, ftFMTBCD, ftBytes, ftTime, ftDateTime,
ftWord, ftInteger, ftUnknown, ftVarBytes, ftUnknown, ftCursor,
ftLargeInt, ftLargeInt, ftADT, ftArray, ftReference, ftDataSet,
ftTimeStamp, ftBCD, ftWideString);
So if you want to get ftBCD Delphi data type for your field then you should ask Embarcadero (owner of Delphi) to restore declaration of the DataTypeMap data type.
Thanks a million!!! The information My Local Cause you've provided helped me a lot!
Last edited by lizy11 on Mon 24 Jun 2013 12:25, edited 2 times in total.