是TCustomSQLDataSet的错吗?
Delphi文档,
ISQLCursor.getColumnPrecision
Description
... ...
Column type Meaning of precision
---------------- ----------------------------------------------
... ... ... ...
fldBCD Number of significant digits in the BCD values.
(Note that the number of decimal places is returned
by the getColumnScale method.)
... ... ... ...
但是SqlExpr单元中的
TCustomSQLDataSet.AddFieldDesc(...)中的代码却是
....
with FieldDesc do
begin
...
if iFldType in [fldFMTBCD, fldBCD] then
begin
iUnits2 := Abs(iUnits2);
if iUnits1 < iUnits2 then // iUnits1 indicates Oracle
//'usable decimals'
iUnits1 := iUnits2;
// ftBCD supports only up to 18-4. If Prec > 14 or Scale > 4,
//make FMTBcd
if (iUnits1 > (MaxBcdPrecision-4)) //!!这里only up to 14位
or (iUnits2 > MaxBcdScale)
or FNumericMapping then
begin
FType := ftFMTBcd;
iFldType := fldFMTBCD;
if (iUnits1 = 38) and (iUnits2 in [0,38]) then
begin
iUnits1 := 32;
iUnits2 := 8;
end;
if iUnits1 > MaxFMTBcdDigits then
iUnits1 := MaxFMTBcdDigits;
end;
end;
end;
当我在数据库声明一个字段为numeric(18,4)时,驱动程序装载为
getColumnPrecision返回18,也就是precision为18
getColumnScale返回4,
我印象中currency可以处理numeric(18,4)类型的字段,
基于时间和空间性能上的考虑,
本来应该为我创建ftBcd也就是Currency类型的字段,
但是却因为这段代码,使得我的字段变成ftFmtBcd字段
我觉得
if (iUnits1 > (MaxBcdPrecision-4)) //!!这里only up to 14位
or (iUnits2 > MaxBcdScale)
or FNumericMapping then
这一句应该为
if (iUnits1 > MaxBcdPrecision) //!!这里only up to 18位
or (iUnits2 > MaxBcdScale)
or FNumericMapping then
不知道大家认为如何,大家发表意见啊