I have got some answers on my question.
Problem: I have stored PLSQL procedure which returns refCursor.
I have to get returned data with datareader.
But When I added parameters db returned
To walk through all returned data I have to write my code so:
NpgsqlTransaction tr = (NpgsqlTransaction) Connection.BeginTransaction();
NpgsqlCommand cursCmd = new NpgsqlCommand("someStoredProcedure",
(NpgsqlConnection) Connection);
cursCmd.Transaction = tr;
NpgsqlParameter rf = new NpgsqlParameter("ref",
NpgsqlTypes.NpgsqlDbType.Refcursor);
rf.Direction = ParameterDirection.InputOutput;
cursCmd.Parameters.Add(rf);
NpgsqlParameter param2 = new NpgsqlParameter("param1",
NpgsqlTypes.Int32);
rf.Direction = ParameterDirection.Input;
cursCmd.Parameters.Add(param2);
NpgsqlDataReader r = cmd.ExecuteReader();
while (r.Read())
{
;// r.GetValue(0);
}
r.NextResult();
while(r.Read())
{
;
}
tr.Commit();
you should notice that you haven't write your parameters in sql like func(:param1)
If you have parameters in your function, assign only the function name to the CommandText property and add parameters to the NpgsqlCommand.Parameters collection as usual. Npgsql will take care of binding your parameters correctly.
But now I have another problem. When I pass just another output parameter to my commandtext.
As a result I have to fields one of them is 0{my first output param} another one is
In oracle i can directly convert RefCursor parameter to datareader but in postgresql i cannot.
Thank you for attention