question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Decimal overflow: bug of Oracle .NET Managed driver

See original GitHub issue

The Decimal column from Oracle DB can produce an overflow of the corresponding .NET decimal.

Eccezione non gestita: System.InvalidCastException: Cast specificato non valido.
   in Oracle.ManagedDataAccess.Client.OracleDataReader.GetDecimal(Int32 i)
   in Oracle.ManagedDataAccess.Client.OracleDataReader.GetValue(Int32 i)
   in Sql2Xlsx.Oracle.<Read>d__3.MoveNext() in C:\dev\SqlServer\Sql2Xlsx\Oracle.cs:riga 102

A workaround is needed.

// decimal overflow workaround 
field.ObjValue =
    field.DataType == "Decimal"?
    DR.GetDouble(i) :
    DR.GetValue(i);

Please forward and fix the code in the Oracle .NET Managed driver, thanks

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
alexkehcommented, Jun 15, 2020

In the next DB release, ODP.NET will introduce a new SuppressGetDecimalInvalidCastException property that will allow suppressing this error and round off the result automatically.

If you wish to preserve the entire NUMBER value, you can do so today with Safe Type Mapping.

0reactions
giuliohomecommented, Nov 23, 2020

It should be a double, not a decimal, and it should not throw an exception… Indeed this is why I kept my workaround and not the proposed-above property

Read more comments on GitHub >

github_iconTop Results From Across the Web

Oracle managed driver ODP.NET with NHibernate 4.0 ...
So the problem of overflow can be resolved without making the field read only (using formula in NHibernate mappings). A custom user type...
Read more >
ODP.NET - cannot read decimal values correctly
I have a problem with ODP.NET managed driver (version 12.1.24160419). I am trying to read a decimal value from a table. In table...
Read more >
Oracle ODP.NET: Resolve “Arithmetic operation resulted in an ...
I ran into this issue as I was moving data from Oracle to SQL Server. ... NET: Resolve “Arithmetic operation resulted in an...
Read more >
Oracle Decimal - Arithmetic operation resulted in an overflow.
Hi, I'm getting an exception from Oracle.DataAccess.Client.OracleDataReader I know, it's not related to XPO, but I'm using it to work with ...
Read more >
Oracle Data Type Mappings - ADO.NET
Decimal or OracleNumber instead of a floating-point value. Using the .NET Framework data type can cause an overflow.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found