I'm facing a problem which occurs when trying to get the results of this simple sql query in NET (c#):
select 1/3 as col from dual
OracleDataReader.GetValue(i)
throws an exception:
Arithmetic operation resulted in an overflow. at Oracle.DataAccess.Types.DecimalConv.GetDecimal(IntPtr numCtx) at Oracle.DataAccess.Client.OracleDataReader.GetDecimal(Int32 i) at Oracle.DataAccess.Client.OracleDataReader.GetValue(Int32 i)
I've discovered that this error occures when number precision goes over 28 digits, so this leads to error:
select round(1/3,29) as col from dual
but this won't
select round(1/3,28) as col from dual
Trying to treat column value in c# as Double gets error "Invalid cast"
Does anyone know any approach to avoid this situation except of ubiquitous rounding of number columns?
Since data type is decimal it must be precise. It's not possible to store 1/3 infinite fraction in a decimal type. In general Conversions from Single or Double to Decimal throw an OverflowException if the result of the conversion is not representable as a Decimal. Thus I need to either read this value as a double or, be sure it's a correct decimal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With