是TCustomSQLDataSet的错吗?

alphax 2004-04-05 06:55:35
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

不知道大家认为如何,大家发表意见啊
...全文
36 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
menggirl 2004-04-08
  • 打赏
  • 举报
回复
能查出Delphi的Bug来?真是厉害,
ttzzj 2004-04-08
  • 打赏
  • 举报
回复
报告委员长,我UP了两个帖!
alphax 2004-04-08
  • 打赏
  • 举报
回复
师座,卑职以为,

看贴不up贴,委员长会不高兴的
alphax 2004-04-07
  • 打赏
  • 举报
回复
alphax 2004-04-07
  • 打赏
  • 举报
回复
谢谢核桃兄弟
aiirii 2004-04-06
  • 打赏
  • 举报
回复
不是很懂, 先參與
alphax 2004-04-06
  • 打赏
  • 举报
回复
我又测了一下,ADODataSet也是把numeric(18,4)的类型映射为currency的
alphax 2004-04-06
  • 打赏
  • 举报
回复
Currency的有效数字可以达到19位,完全表示numeric(18,4)的数

至少TIBCustomDataSet也是这么干的,它把numeric(18,4)的类型映射为currency字段

我也测试了,用下面的值
-922337203685477.5808
922337203685477.5807
写入一个numeric(18,4)类型的字段

然后关闭再打开再读出得出正确的结果
hthunter 2004-04-06
  • 打赏
  • 举报
回复
那就再up一下,呵呵
alphax 2004-04-06
  • 打赏
  • 举报
回复
没人用dbexpress?

帮忙up一下也好
alphax 2004-04-06
  • 打赏
  • 举报
回复
yczyk 2004-04-06
  • 打赏
  • 举报
回复
能查出Delphi的Bug来?真是厉害,不过据我所知BCD字段只在BDE里会产生数据精度问题。所以在BDE里就有这么一个所选:EnableBCD。呵呵,其他的看不懂!
alphax 2004-04-06
  • 打赏
  • 举报
回复
hunterht 2004-04-05
  • 打赏
  • 举报
回复
我印象中currency可以处理numeric(18,4)类型的字段,
****************
到底是否如你所说,用实际数据测试一下不就知道结果了?
Borland Delphi 2005 Architect Update 3----------Report #: Short Description: Rating: Status12241 IntToHex returns lowercase letters0.00 of 5 Closed11881 TStringStream constructor for .NET sets Position incorrectly0.00 of 5 Closed11787 Access violation using Code Insight when editing the uses clause0.00 of 5 Closed11759 TList instance leaked in DBCommon.pas when using IN operator in Filter expression5.00 of 5 Closed11651 New EllipsisPosition property causes text to be invisible & process to hang5.00 of 5 Closed11471 Cannot manage StarTeam association since applying Update20.00 of 5 Closed11353 (strict) protected nested class become public3.67 of 5 Closed11314 Too much inlining yields unstable compiled code.0.00 of 5 Closed11266 Inline causes compile error : F2084 Internal Error SCR765.00 of 5 Closed11193 Inlined function affects working of the enclosing for loop0.00 of 5 Closed11184 [Fatal Error] F2084 Internal Error: ILLK26340.00 of 5 Closed11069 Compact the TApplication.ProcessMessage code fragment for Unicode handling5.00 of 5 Closed10918 TColorBox control custom color selection causes AV0.00 of 5 Closed10873 Internal error: URW 793 when using constant struct with enums2.00 of 5 Closed10861 Access Violation when compiling code with default index property0.00 of 5 Closed10772 Designer improperly handles controls tagged with [ToolboxItem]0.00 of 5 Closed10669 TWideStrings has no GetEnumerator method0.00 of 5 Closed10661 Switching between form and source view cause long delay4.67 of 5 Closed10567 Ability to create all VCL packages0.00 of 5 Closed10498 D2005: DataSet lots of methods missing in code completion0.00 of 5 Closed10450 The Ellipse is drawn over some of the caption text when a form is docked in IDE0.00 of 5 Closed10381 Constant array of procedural types crashes compiler5.00 of 5 Closed10376 The Delphi 2k5 IDE UpTime & project loading is very SLOW4.00 of 5 Closed10314 Error Insight fails to flag an error4.00 of 5 Closed10248 Alignment Palette in VCL form designer malfunctions5.00 of 5 Closed10190 List view selected item no longer selected5.00 of 5 Closed10009 Double-click in the Search Results window0.00 of 5 Closed9912 Press Enter on Component crashes Delphi 20050.00 of 5 Closed9847 Transactional Object Wizard Missing0.00 of 5 Closed9712 The XML documentation feature doesn't associate comments with the correct symbols5.00 of 5 Closed9690 "Cannot focus a disabled or invisible window" in IDE0.00 of 5 Closed9666 Code Completion doesn't show all available items when using overload5.00 of 5 Closed9639 Active Form wizard not available in Delphi 2005 but mentioned in online help5.00 of 5 Closed9634 IDE response too SLOW4.63 of 5 Closed9578 TXPManifest + TFrame + TLabel + TRadioGroup = bad5.00 of 5 Closed9477 Delphi .NET assembly references with strong names5.00 of 5 Closed9254 Incorrect reference public key token included into Delphi8 strong-named assembly metadata4.00 of 5 Closed9021 Memory Leak in TreeView0.00 of 5 Closed8866 Assigning long string values (greater than 8192 characters) to TStringFields results in access violation.5.00 of 5 Closed8785 Filter or Ranges on Nested Dataset's should restrict master as well.0.00 of 5 Closed8417 TCustomSQLDataSet.GetFieldData implementation0.00 of 5 Closed8229 Error in code when database doesn't support schema/owner names5.00 of 5 Closed8032 Show modified code in the scrollbar0.00 of 5 Closed8021 TIndexDef.Assign Doesn't copy DescFiels and CaseInsFields5.00 of 5 Closed8001 SQLDataset doesn't call .Close on dbExpress driver cursor when closing5.00 of 5 Closed7912 TCustomClientdataset: properties "IndexDefs" and "IndexName" should be public0.00 of 5 Closed7872 double exception in method TDataSetProvider.InternalGetRecords5.00 of 5 Closed7809 SetOptionalParam don't work0.00 of 5 Closed7768 An Easy Feature Request: TDataset.CopyFields4.00 of 5 Closed7290 Grid's functionality enhancement5.00 of 5 Closed7199 Class Completion erroneously adds fields to a complete class if the getter functions starts with F5.00 of 5 Closed7082 Add SSE3 / PNI instructions to the BASM5.00 of 5 Closed7005 New control request - TDBStaticText - Add possibility to have Edge Borders0.00 of 5 Closed6985 Add node for unit name in Find in Files results in Message Window0.00 of 5 Closed6803 WebToolBar problem with buttons0.00 of 5 Closed6558 AV in DBGrid when destroying DataSet0.00 of 5 Closed6428 Labels disappear with XPManifest5.00 of 5 Closed6368 Resolving lookup- & calculated fields to datafields4.00 of 5 Closed6238 DBNavigator and DBGrid compliant with Federal Section 5080.00 of 5 Closed6021 Labels not visible in Windows XP0.00 of 5 Closed5951 Internal error: SY5764.44 of 5 Closed5812 TComboBox.Focused method does not always return good results.1.00 of 5 Closed5803 Unable to delete component if code editor minimized in saved desktop5.00 of 5 Closed5763 Cannot debug datamodule containing many objects0.00 of 5 Closed5699 Apache shared modules do not work with Apache 2.0.4x5.00 of 5 Closed5592 New event OnValidate that is fired before applying updates2.00 of 5 Closed5336 fatal error: Internal Error: L6812.33 of 5 Closed5283 Cannot read complete compiler error message.0.00 of 5 Closed5280 MessageDlg returns mrNone instead of mrCancel when aborted5.00 of 5 Closed5248 Assert fails to break and leaves FPU invalid op exception set.4.50 of 5 Closed4627 Cannot assign -2147483648 into INTEGER Variable4.00 of 5 Closed4624 A way to set both Width and Height of TBitmap (speed reason)4.85 of 5 Closed4581 Field description and Label3.00 of 5 Closed4444 IncMilliSeconds...IncHour with DateTime<0 wrong0.00 of 5 Closed4343 Proposal of modification of the TDataSet.Post method in DB.pas unit1.00 of 5 Closed4184 Delphi DLL using sharemem called from VC++ exe AV on exit3.25 of 5 Closed4172 tFrames and XPMan hiding controls5.00 of 5 Closed3850 TGraphicControl descendants invisible in frames with XP Manifest4.60 of 5 Closed3792 TryEncodeDateTime not correct for dates before Dec. 30, 18995.00 of 5 Closed3776 Add full IDL support0.00 of 5 Closed3718 Automatic Required setting of TField not consistent with SQL3.71 of 5 Closed3542 Strange limits in property CommandText2.40 of 5 Closed2881 DBGrid doesn't repaint when Enabled changed.5.00 of 5 Closed2625 Impossible to open a .TLB into the TLB Editor if missing uses reference3.50 of 5 Closed2608 Compiler crashes, dcc70.dll Read of address 000000004.00 of 5 Closed2572 Unable to sort on columns in module view3.00 of 5 Closed2382 TListView doesn't update correctly in OwnerData mode.4.00 of 5 Closed2276 'deprecated' warning appears when it shouldn't4.31 of 5 Closed2258 Failure to parse/compile integer constant --2147483648 and lower4.86 of 5 Closed2236 Delphi converts Text DFM's to binary with these steps4.71 of 5 Closed1685 Compiler error message refers to HIGH when it should be LOW3.43 of 5 Closed1455 GetRange method3.38 of 5 Closed1209 Context help does not work for TComboboxEx3.67 of 5 Closed1177 ResourceString limitation of 1024 characters3.89 of 5 Closed(出处:www.borland.com)

5,402

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧