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

发布于 2024-12-08 19:41:34 字数 2056 浏览 0 评论 0原文

当我使用 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,

代码如下:

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;

查询:

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倚栏听风 2024-12-15 19:41:34

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

简而言之,更改您的查询,以便将具有更高精度数字的所有列四舍五入到您需要的小数位数:

示例:

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

应该可以解决您的问题。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文