Oracle 中的 IDataReader 返回十进制值时溢出
我有一些代码负责将数据从 IDataReader
转换为 IronPython.Runtime.List
的 PythonTuples
。相同的代码用于多种不同类型的数据库连接(包括 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,唯一与提供商无关的方法是对 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.
它可能不完全是您正在寻找的内容,但
System.Data.Common.DbDataReader
类有一个GetProviderSpecificValues
函数,可以执行您想要的操作It may not be exactly what you're looking for, but the
System.Data.Common.DbDataReader
class has aGetProviderSpecificValues
function that may do what you want