Delphi BDE('Type mismatch for field "xxxx", expecting: Integer actual: Float')

碰到了这个问题,数据库中某字段,比如l_id类型是number(10)
IDE:delphi5;
数据库连接方式:BDE
数据库:oracle 10.2.0

问题出现在添加字段的时候,l_id是number(10)照理说add fields应该对应TIntegerField
可是选出来的结果是TFloatField。
手动修改pas和dfm文件中字段类型后,将TQuery置为true报错
('Type mismatch for field "xxxx", expecting: Integer actual: Float')
连接不上

对于这里,应该有一个类型转换的问题,为何本来是整型的却被delphi,精确的说bde给识别成了float。google一下,中文网页优先,有人有碰到该问题,只是无人解答,或者没有完全搞定
CodeGear中终于发现提示了:
[url]http://www.tek-tips.com/viewthread.cfm?qid=75814&page=352[/url]

亮点在这一段:
There is an TIntegerField which is receiving a field from a query. The declaration of the field in the database is number (10, 0). It is a known attribute of Oracle that all number fields are stored internally as floats. The automatic conversion of these fields in BDE is governed by settings in the BDE Admin utility under the Configuration/Drivers/Native key. For Oracle 8i to enable the return of integers you must change the entries for DLL32, Vendor Init and enable integers. This much I think is true.

检查我的BDEADMIN,drivers中的native-oracle中,将enable integer置为true,关闭重启生效,再到D5中试,NND,还不行。再检查database中建的实例,这里也有一个enable integer,修改之,再试,终于可以识别出TIntegerField了。

【原因分析】Oracle中是没有整型这个概念,只有一个数据类型,number,可以定义整型和浮点型,最终在oracle的存储方式中都被存为浮点型(其实到底都是字符串);而BDE中有对数据类型转换的控制开关,平时是置为false的(除integer外还有BCD)。需要时要打开。

【评论】BDE引发的血案

【结论】Delphi真的没落了,关注者甚少...

你可能感兴趣的:(Delphi)