oracle 执行 pl/sql 查询时出现溢出错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7688645/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 00:21:05  来源:igfitidea点击:

Getting overflow error when executing pl/sql query

c#oracleado.netplsql

提问by user74042

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.

当我使用我的 C# 代码运行 pl/sql 查询 [通过存储过程] 时,出现错误:如何解决相同的问题?请指教。注意:我在代码中为 providerSpecificTypes 传递了 false。

 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

回答by

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.

所选列值之一的精度超出 .Net 的十进制类型。解决此问题的最佳方法是将列值四舍五入到可管理的预置大小。通常我会将它们四舍五入到小数点后 2 位,因为我不再需要了,您可能需要根据需要进行选择。

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.

应该可以解决您的问题。