Oracle Stored Proc to Return a Recordset (.Net Side)


/ Published in: C#
Save to your folder(s)

Very important to set the RefCursor Type. Otherwise you get the PLS-00306 Error 'Wrong Number or types of arguments'


Copy this code and paste it in your HTML
  1. Oracle.DataAccess.Client.OracleConnection OraConn = new Oracle.DataAccess.Client.OracleConnection();
  2. OraConn.ConnectionString = "Data Source=DBName;User Id=MyUser;Password=MyPW;";
  3. OraConn.Open();
  4. Oracle.DataAccess.Client.OracleCommand OraComm = new Oracle.DataAccess.Client.OracleCommand("RobCursorTestProc", OraConn);
  5. OraComm.CommandType = CommandType.StoredProcedure;
  6. OraComm.Parameters.Add("Cursor", Oracle.DataAccess.Client.OracleDbType.RefCursor, ParameterDirection.Output);
  7. Oracle.DataAccess.Client.OracleDataReader OraDR = OraComm.ExecuteReader();
  8. if (OraDR.Read())
  9. {
  10. MessageBox.Show(OraDR.GetName(0));
  11. MessageBox.Show(OraDR.GetValue(0).ToString());
  12. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.