title: Attempting to call an Oracle Stored Function that returns a ref cursor to C#
body: <p>I have been pulling my hair trying to get a resultset back from an oracle stored function that returns a ref cursor.</p>
  
  <p>Here is the declaration for by Oracle Stored Function:</p>
  
  <pre><code>TYPE GetInspectorCursor IS REF CURSOR;
  FUNCTION GetInspectorInformation
     (inUserID IN inspectortable.userid%type,
      inPassword IN inspectortable.password%type,
      inCompanyID IN inspectortable.cid%type,
      inSubCompanyID in inspectortable.scid%type,
      outErrorcode OUT NUMBER)
  RETURN GetInspectorCursor;
  </code></pre>
  
  <p>Here is my c# program to get the result set:</p>
  
  <pre><code>        String connString = "DATA SOURCE=PEOPLE.WORLD;PASSWORD=password;PERSISTSEC CURITY INFO=True;USER ID=userid";
  
  
          DataSet ds;
          OracleDataAdapter myAdapter = null;
          Oracle.DataAccess.Types.OracleRefCursor refCursor = null;
  
          OracleConnection myCon = new OracleConnection(connString);
  
          String commandText = "schema.package.GetInspectorInformation";
  
          OracleCommand cmd = new OracleCommand(commandText, myCon);
          cmd.CommandType = CommandType.StoredProcedure;
  
  
          // inpectorID
          OracleParameter param = new OracleParameter();
          param.OracleDbType = OracleDbType.Char;
          param.Direction = ParameterDirection.Input;
          param.Value = "JOHN";
          cmd.Parameters.Add(param);
  
          // inspector Password
          OracleParameter param2 = new OracleParameter();
           param2.OracleDbType = OracleDbType.Char;
           param2.Direction = ParameterDirection.Input;
           param2.Value = "12345";
          cmd.Parameters.Add(param2);
  
          // VALUE 1
          OracleParameter param3 = new OracleParameter();
           param3.OracleDbType = OracleDbType.Char;
           param3.Direction = ParameterDirection.Input;
           param3.Value = "VA1";
          cmd.Parameters.Add(param3);
  
          // VALUE 2
          OracleParameter param4 = new OracleParameter();
           param4.OracleDbType = OracleDbType.Char;
           param4.Direction = ParameterDirection.Input;
           param4.Value = "VA2";
          cmd.Parameters.Add(param4);
  
          // outParam Error Code
          OracleParameter param5 = new OracleParameter();
           param5.OracleDbType = OracleDbType.Decimal;
           param5.Direction = ParameterDirection.Output;
           //param5.IsNullable = true;
          cmd.Parameters.Add(param5);
  
  
          OracleParameter param6 = new OracleParameter();
           param.ParameterName = "RefCursor";
           param6.OracleDbType = OracleDbType.Object;
           param6.OracleDbTypeEx = OracleDbType.RefCursor;
           param6.Direction = ParameterDirection.ReturnValue;
           ///param6.IsNullable = false;
           cmd.Parameters.Add(param6);
  
  
           myCon.Open();
  
           cmd.ExecuteNonQuery();
  
  
          refCursor = (Oracle.DataAccess.Types.OracleRefCursor)cmd.Parameters["RefCursor"].Value;
          myAdapter = new OracleDataAdapter("", myCon);
          ds = new DataSet("testDS");
          myAdapter.Fill(ds, refCursor);
  
          // Clean up
          cmd.Dispose();
          myCon.Close();
          myCon.Dispose();
  </code></pre>
  
  <p>On myCon.Open() call I get:</p>
  
  <pre><code> ORA-06550: line 1, column 15:
   PLS-00306: wrong number or types of arguments in call to 'GETINSPECTORINFORMATION'
   ORA-06550: line 1, column 7:
   PL/SQL: Statement ignored
  </code></pre>
  
  <p>Would someone be kind enough to spare a few brain cells and me tell what/which parameter is being passed incorrectly?</p>
  
  <p>Thanks!!!!</p>