Parameter issue with Oracle RefCursor

随声附和 提交于 2019-12-11 16:47:45

问题


I'm using ODP.NET (migrating from Microsoft's provider), and I have got stuck on a stored procedure that returns a refcursor. I have the following PL/SQL procedure (I have changed it a little bit to make it more general):

PROCEDURE MyProc(parameter_no1 IN NUMBER, parameter_no2 IN NUMBER, RETCURSOR OUT ret_type) AS
BEGIN
  OPEN RETCURSOR FOR
  SELECT   ad.logo logo 
  FROM    tab_a a, tab_h h 
  WHERE  a.id IS NOT NULL 
  AND    a.h_id = h.id 
  AND    a.no1 = parameter_no1
  AND    a.no2= parameter_no2;
END HanteraLogotype;

And then I have the folloing C# code to call it:

internal void RefCursorDataReader()
{
  OracleCommand cmd = new OracleCommand("ABC$MYPACKAGE.MyProc", new OracleConnection(_constr));
  cmd.CommandType = CommandType.StoredProcedure;
  cmd.Connection.Open();
  cmd.BindByName = true;

  OracleParameter p = cmd.Parameters.Add("parameter_no1", OracleDbType.Decimal);
  p.Value = 12345678;
  p.Direction = ParameterDirection.Input;

  p = cmd.Parameters.Add("parameter_no2", OracleDbType.Decimal);
  p.Value = 123456;
  p.Direction = ParameterDirection.Input;

  p = cmd.Parameters.Add("RETCURSOR", OracleDbType.RefCursor);
  p.Direction = ParameterDirection.Output;

  OracleDataReader reader = cmd.ExecuteReader();

  if (reader.Read())
  {
    System.Diagnostics.Debug.WriteLine(reader[0].GetType().ToString());
  }

  cmd.Connection.Close();
}

And when I run this, I keep getting this exception:

ORA-03106: fatal two-task communication protocol error

I have tried numerous different variations of parameters, their type, order etc, but nothing seems to help. It's the reader.Read() that throws the exception. I would really appreciate assistance on this one!

Added: the ret_type is defined as:

TYPE ret_type IS REF CURSOR;


回答1:


That looks like a bug. The 3106 error is a bad error that should never happen. I'm sure there's a workaround though!!

The best place to ask ODP.NET questions is over on the OTN ODP.NET forum. If I were you I would post this over there:

http://forums.oracle.com/forums/forum.jspa?forumID=146&start=0

Also search that particular forum for "3106"




回答2:


I upgraded to 11G ODP.NET



来源:https://stackoverflow.com/questions/1210956/parameter-issue-with-oracle-refcursor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!