user74042
user74042

Reputation: 739

Getting overflow error when executing pl/sql query

When I run pl/sql query[through a stored procedure] using my C# code,I get an error: How do I resolve the same?Please advise. Note:am passing false for providerSpecificTypes in the code.

 Error Message:
 System.Data.OracleClient.OracleException: OCI-22053: overflow error   
 at System.Data.Common.DbDataAdapter.FillErrorHandler(Exception e, DataTable dataTable, Object[] dataValues)    
 at System.Data.Common.DbDataAdapter.FillLoadDataRowChunk(SchemaMapping mapping, Int32 startRecord, Int32 maxRecords)    
 at System.Data.Common.DbDataAdapter.FillFromReader(Object data, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)    
 at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
 at System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)    
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command,

Here is the code:

DataSet ds = new DataSet(); 
        try 
        { 
            this.OpenDBConnection(); 
            this.dbAdapter.ReturnProviderSpecificTypes = providerSpecificTypes; 
            this.dbAdapter.Fill(ds); 
        } 
        catch 
        { 
            throw; 
        } 
        finally 
        { 
            CloseDBConnection(); 
            this.cmd.Parameters.Clear(); 
        }
            return ds;

Query:

SELECT client_id, TO_CHAR (business_dt, 'MM/DD/YYYY') AS business_dt 
       , mkt_type
       , mkt_name
       , product_name
       , period
       , TO_CHAR (start_dt, 'MM/DD/YYYY') AS start_dt
       , TO_CHAR (end_dt, 'MM/DD/YYYY') AS end_dt
       , duration
       , term
       , NULL AS strike_price
       , instrument_type
       , final_price
       , NULL AS product_price
       , units
       ,  NULL AS expiry_dt
       , mkt_close
       , cons_flag

Upvotes: 14

Views: 16623

Answers (1)

user474407
user474407

Reputation:

One of the selected column value is having a precision beyond the .Net's decimal type. The best way to resolve this issue is to ROUND your column values to a manageable prevision size. Normally I round them to 2 digits of decimal place as I would not need anymore than that, you may want to choose according to your need.

So in short, change your query so that all columns with a higher precision number to be rounded off to the number of decimals you need:

Example:

Select ROUND(final_price, 2) From <your table>

should address your problem.

Upvotes: 28

Related Questions