问题
I am trying to call the postgresql v11 store procedure (not function) with InOut parameter as RefCursor? using Npgsql v4.0.8 from ado.net code 4.5 framework. but not able to read the data from it.
even have tried using Npgsql v4.1.2(latest version) from ado.net code 4.6.1 framework also but still then not able to read the data from store procedure.
what is the solution? for it. please provide sample code to fetch the value.
my sample code:
public void PopulateTableFromCursor()
{
OpenConnection();
NpgsqlDataAdapter adapter = new NpgsqlDataAdapter();
NpgsqlCommand command = this.Connection.CreateCommand();
NpgsqlParameter paRef1 = new NpgsqlParameter("@ref1", NpgsqlTypes.NpgsqlDbType.Refcursor);
paRef1.Direction = ParameterDirection.InputOutput;
paRef1.Value = "ref1";
command.Parameters.Add(paRef1);
command.CommandTimeout = 60000;
command.CommandText = "call public.sp_admin_getconfiguredusers('ref1');fetch all \"ref1\"";
try
{
command.ExecuteNonQuery();
var result = paRef1.Value;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
finally
{
this.Connection.Close();
}
}
来源:https://stackoverflow.com/questions/58979996/how-to-call-the-postgres-v11-stored-proceduresnot-function-with-inout-paramete