Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

InvalidCastException retrieving a high precision decimal

user4977350Feb 16 2017 — edited Dec 3 2019

If a select statement returns a number field with precision greater then the max precision of a .net decimal it throws an InvalidCastException from Oracle.ManagedDataAccess.Client.OracleDataReader.GetDecimal().

A simple way this can be seen is:

OracleCommand cmd = // get the command

cmd.CommandText = "SELECT 1/3 FROM DUAL";

object x = cmd.ExecuteScalar(); // InvalidCastException

Whilst this can obviously be fixed by using CAST or ROUND in the query are there any plans to address this problem in the driver?

Tested using 64-bit ODAC 12c Release 4 (12.1.0.2.4).

This post has been answered by user8091922 on Jun 27 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 25 2017
Added on Feb 16 2017
2 comments
5,496 views