执行pl/sql查询时出现溢出错误
当我使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所选列值之一的精度超出了 .Net 的小数类型。解决此问题的最佳方法是将列值舍入为可管理的预置大小。通常我将它们四舍五入到小数点后两位,因为我不需要更多的数字,您可能需要根据您的需要进行选择。
简而言之,更改您的查询,以便将具有更高精度数字的所有列四舍五入到您需要的小数位数:
示例:
应该可以解决您的问题。
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:
should address your problem.