我正在将Npgsql与.Net应用程序一起使用,它可以正常运行,但是有些 给出以下错误。
“ NpgsqlException-错误:57014:由于用户请求而取消语句”
这是返回多个数据集的代码。在内部,我在存储过程中使用了refcursor。
public List<DataTable> ExecuteDatasetForMultipleResultset(CommandType commandType, string query, NpgsqlParameter[] npgsqlParameters, List<string> outputparameters)
{
using (NpgsqlCommand command = GetCommand(query, npgsqlParameters, commandType))
{
try
{
List<DataTable> tables = new List<DataTable>();
NpgsqlTransaction t = command.Connection.BeginTransaction(IsolationLevel.ReadUncommitted);
command.ExecuteNonQuery();
//command.CommandTimeout = 60;
foreach (var item in outputparameters)
{
string innerquery = "fetch all in \"" + item.ToString().Trim() + "\";";
command.CommandType = CommandType.Text;
command.CommandText = innerquery;
NpgsqlDataAdapter da = new NpgsqlDataAdapter(command);
DataSet myDS = new DataSet();
da.Fill(myDS);
tables.Add(myDS.Tables[0]);
}
t.Commit();
return tables;
}
catch (Exception Ex)
{
throw Ex;
}
finally
{
command.Connection.Close();
}
}
}
异常日志:
{
"ClassName": "Npgsql.NpgsqlException",
"Message": "ERROR: 57014: canceling statement due to user request",
"Data": null,
"InnerException": null,
"HelpURL": null,
"StackTraceString": " at Npgsql.NpgsqlState.d__0.MoveNext()\r\n at Npgsql.ForwardsOnlyDataReader.GetNextResponseObject(Boolean cleanup)\r\n at Npgsql.ForwardsOnlyDataReader.GetNextRow(Boolean clearPending)\r\n at Npgsql.ForwardsOnlyDataReader.Read()\r\n at System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping)\r\n at System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)\r\n at System.Data.Common.DataAdapter.Fill(DataSet dataSet, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)\r\n at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)\r\n at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)\r\n at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)\r\n at MidOfficeWebservice.NPgSQL.Npgsql_Helper.ExecuteDatasetForMultipleResultset(CommandType commandType, String query, NpgsqlParameter[] npgsqlParameters, List`1 outputparameters)",
"RemoteStackTraceString": null,
"RemoteStackIndex": 0,
"ExceptionMethod": "8\nMoveNext\nNpgsql, Version=2.2.3.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7\nNpgsql.NpgsqlState+d__0\nBoolean MoveNext()",
"HResult": -2147467259,
"Source": "Npgsql",
"WatsonBuckets": null,
"errors": [{
"Severity": "ERROR",
"Code": "57014",
"Message": "canceling statement due to user request",
"Detail": "",
"Hint": "",
"Position": "",
"InternalPosition": "",
"InternalQuery": "",
"Where": "",
"File": "postgres.c",
"Line": "3006",
"Routine": "ProcessInterrupts",
"SchemaName": "",
"TableName": "",
"ColumnName": "",
"DataTypeName": "",
"ConstraintName": "",
"ErrorSql": "fetch all in \"tbl_brokerage_segment_sub\";"
}]
}