Oracle and Decimal (precision 38)

Posts   
 
    
mainfram
User
Posts: 6
Joined: 26-May-2004
# Posted on: 30-Sep-2010 10:14:28   

Hi,

I am using LLBLGen 3, self servicing set and Oracle .NET driver ODP.NET. I get the "Arithmetic operation resulted in an overflow" when I do a GetMulti on a table that actually has a large number within the data.

The error is thrown by the oracle driver because it is trying to cast it to Decimal which is precision 18 I believe.

Oracle has a OracleDecimal type defined within the driver, is there a way to tell LLBLGen to use it instead of System.Decimal. I've tested this with straight ADO.NET code below. DataAdapter has a flag ReturnProviderSpecificTypes in which case DataAdapter does return the OracleDecimal and the code works. Without it, a same exception as when doing GetMulti gets thrown...


                Oracle.DataAccess.Client.OracleConnection objOracleConnection = new Oracle.DataAccess.Client.OracleConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString.Oracle (ODP.NET)"]);
                Oracle.DataAccess.Client.OracleCommand objOracleCommand = new Oracle.DataAccess.Client.OracleCommand();
                objOracleCommand.Connection = objOracleConnection;
                objOracleCommand.CommandType = System.Data.CommandType.Text;
                objOracleCommand.CommandText = "SELECT * FROM DF_INTEG_TEST.\"FrameworkTest\"";
                Oracle.DataAccess.Client.OracleDataAdapter objSqlDataAdapter = new Oracle.DataAccess.Client.OracleDataAdapter(objOracleCommand);
                
                objSqlDataAdapter.ReturnProviderSpecificTypes = true;

                System.Data.DataSet objDataSet = new System.Data.DataSet();
                objSqlDataAdapter.Fill(objDataSet);

Just looking for some thoughts... I actually have a workaround for this (change the schema to use precision 18 numbers). Just for reference our schema script was written to create INTEGER oracle field (which is precision 38 number).

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39898
Joined: 17-Aug-2003
# Posted on: 30-Sep-2010 10:57:35   

Override in a partial class of CommonDaoBase the method HandleValueReadErrors, which is the same as the one you'd override in a partial class of DataAccessAdapter.

There's no 'ReturnProviderSpecificTypes' flag on the DataAccessAdapter, I think you refer to the DbDataReader class?

Frans Bouma | Lead developer LLBLGen Pro
mainfram
User
Posts: 6
Joined: 26-May-2004
# Posted on: 01-Oct-2010 04:15:35   

I am referring to ADO.NET DataAdapter class which has the ReturnProviderSpecificTypes. I was just wondering if there is a way for LLBLGen designer to allow me to select OracleDecimal as the target .NET type.

I understand that then my code is dependent on oracle and can't be easily replaced with another database engine.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39898
Joined: 17-Aug-2003
# Posted on: 01-Oct-2010 10:24:38   

mainfram wrote:

I am referring to ADO.NET DataAdapter class which has the ReturnProviderSpecificTypes. I was just wondering if there is a way for LLBLGen designer to allow me to select OracleDecimal as the target .NET type.

I understand that then my code is dependent on oracle and can't be easily replaced with another database engine.

Only through a typeconverter, but in any way, the exception can't be avoided. The main issue is that the datareader does the conversion to decimals internally BEFORE the o/r mapper gets the values. We call datareader.GetValues() to get the array of values from the datareader, but this internally inside ODP.NET's datareader triggers the exception, as the value is stored inside the decimal which causes the overflow.

Frans Bouma | Lead developer LLBLGen Pro