Delphi 6 与 ADO + Oracle返回不同​​精度的NUMBER,产生BCD溢出

发布于 2024-07-26 21:07:30 字数 673 浏览 3 评论 0原文

我在使用 Delphi 6 + Oracle 10gR2 + ADO + ClientDataSet 时遇到问题。

每当我在字段 NUMBER(19,9) 上运行聚合函数时,结果列都会向 Delphi 返回 NUMBER 数据类型,并且在某些机器上它会加载为精度为 38 的 TBCDField,并且一切顺利,但在某些机器上它作为精度为 255 的 TBCDField 加载,并且该字段出现 BCD 溢出。

要复制该问题,只需创建一个包含 NUMBER (19,9) 列的表,然后运行 ​​SELECT SUM(column_name) column_name FROM table_name > 按列名分组。

尽管该列是 NUMBER(19,9),但结果列将是未定义精度的 NUMBER。

在 Delphi 中,将查询加载到 ADOQuery 中,并链接到它的 DataSetProvider 和链接到 DataSetProvider 的 ClientDataSet。 在我调用 ClientDataSet.Open 后,在某些机器上,我在 NUMBER 字段上收到 BCD 溢出消息,但在很多机器上它工作得很好。

当 midas.dll、ADO、服务器、用户、oracle 客户端在两台机器上都相同时,为什么我在某些机器上得到 255 精度? 有任何想法吗?

I'm having a problem with Delphi 6 + Oracle 10gR2 + ADO + ClientDataSet.

Whenever I run a aggregate function on a field NUMBER(19,9), the resulting column returns a NUMBER datatype to Delphi, and on some machines it loads as a TBCDField with a precision of 38, and everything goes well, but on some machines it loads as a TBCDField with a precision of 255, and I get a BCD overflow on the field.

To replicate the problem, just create a table with a column NUMBER (19,9), and run a SELECT SUM(column_name) column_name FROM table_name GROUP BY column_name.

Despite the fact that the column is a NUMBER(19,9), the resulting column will be a NUMBER with no precision defined.

In Delphi, load the query into a ADOQuery, with a DataSetProvider linked to it and a ClientDataSet linked to the DataSetProvider. After I call the ClientDataSet.Open, on some machines I get a BCD overflow message on the NUMBER field, but in a lot of machines it works nice.

Why am I getting this 255 precision on some machines, when the midas.dll, ADO, server, user, oracle client are all the same on both machines? Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

琴流音 2024-08-02 21:07:30

尝试

Select **CAST(NUMBER_FLD as VARCHAR2(15))** as NUMBER_FLD from DUAL;

在 Delphi 上进行类型转换,它是一个 StringField (ClientDataset) 组件,但如果您通过别名获取,例如 CdsOracleSQL.FieldByname('NUMBER_FLD').AsFloatCdsOracleSQLNUMBER_FLD.AsFloat 有效。

我不知道为什么 BCDField 丢失小数分隔符并像整数一样工作......

Try type cast

Select **CAST(NUMBER_FLD as VARCHAR2(15))** as NUMBER_FLD from DUAL;

On Delphi, is a StringField (ClientDataset) component, but if you get by alias, like CdsOracleSQL.FieldByname('NUMBER_FLD').AsFloat or CdsOracleSQLNUMBER_FLD.AsFloat works.

I dont know why BCDField loses the decimal separator and works likes a integer...

祁梦 2024-08-02 21:07:30

我没有给你任何明确的答案,但你确定两台机器上都有相同版本的客户端 dll 吗? 可能安装了其他干扰软件。 尝试在客户端计算机上运行 Windows Process Explorer 并确认 dll您认为您正在使用的是您的客户端应用程序实际正在使用的那些。

I don't have any definitive answer for your, but are you positive you have the same versions of the client dlls on both machines? There may be other software installed that is interfering. Try running Windows Process Explorer on the client machines and confirm that the dlls you think you are using are the ones that are actually being used by your client applications.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文