Oracle 中的 IDataReader 返回十进制值时溢出

发布于 2024-10-02 00:18:38 字数 404 浏览 2 评论 0原文

我有一些代码负责将数据从 IDataReader 转换为 IronPython.Runtime.ListPythonTuples。相同的代码用于多种不同类型的数据库连接(包括 Access、Oracle 和 MySql)。

当游标包含高精度值时,Oracle 的 OracleDecimal 数据类型在调用 dataReader.GetValues() 时会导致溢出。此问题已有详细记录,并且解决方案始终涉及使用 OracleDataAdapter 上的特定方法。我只有一个 IDataReader 接口。

有没有办法解决这个问题而不将我的代码专门绑定到 ODP.NET?肯定有某种方法可以以与提供商无关的方式获取这些数据吗?

I have some code that is responsible for converting data from an IDataReader into an IronPython.Runtime.List of PythonTuples. This same code is employed for several different kinds of database connections (including Access, Oracle and MySql).

Oracle's OracleDecimal datatype causes an overflow when calling dataReader.GetValues() when the cursor contains a value with a large precision. This issue has been well documented, and the solutions always involve using specific methods on the OracleDataAdapter. I only have an IDataReader interface.

Is there any way around this issue without binding my code specifically to ODP.NET? Surely there must be some way to get at this data in a provider-agnostic way?

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

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

发布评论

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

评论(2

伊面 2024-10-09 00:18:38

据我所知,唯一与提供商无关的方法是对 select 语句中的值进行四舍五入。我发现四舍五入到小数点后 15 位通常可以解决问题。

The only provider agnostic method that I am aware of is to round the values in your select statement. I've found that rounding to 15 decimal places usually does the trick.

絕版丫頭 2024-10-09 00:18:38

它可能不完全是您正在寻找的内容,但 System.Data.Common.DbDataReader 类有一个 GetProviderSpecificValues 函数,可以执行您想要的操作

It may not be exactly what you're looking for, but the System.Data.Common.DbDataReader class has a GetProviderSpecificValues function that may do what you want

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