Basic Stored Procedure to Populate a Dataset - Returning an Error
721872Sep 11 2009 — edited May 6 2010Hello All:
I come from a SQL Server background and have created extensive stored procedures in SQL Server to work with .Net, so I fully admit my limitations with Oracle and working with .Net in asking this question, as this is my first attempt in trying to get an Oracle Stored Procedure to work, sending back data to my .Net code, so anything you can do to help will be greatly appreciated.
I have the stored procedure below, which compiled (I am not sure it is even correct though to do what I want, which is basically return a recordset that I want in the end to populate a dataset using the .Fill method of my adapter).
CREATE OR REPLACE PROCEDURE spAllocationSelectAll(
p_Cursor OUT SYS_REFCURSOR)
IS
BEGIN
OPEN p_Cursor FOR
SELECT
AllocationID,
AllocationName
FROM
lkAllocation
ORDER BY
AllocationName;
END spAllocationSelectAll;
I don't know how to call this stored procudure from my .Net Code. I am getting an errory saying saying ORA-06550 as the error code.
.Net Code:
oConn = new OracleConnection(ConfigurationManager.ConnectionStrings.ConnectionString);
OracleCommand oCommand = new OracleCommand();
oCommand.Connection = oConn;
oCommand.CommandText = "spAllocationSelectAll";
oCommand.CommandType = CommandType.StoredProcedure;
oCommand.Parameters.Add("curGroupSizings", OracleType.Cursor).Direction = ParameterDirection.Output;
oAdapter = new OracleDataAdapter(oCommand);
ds = new DataSet();
oAdapter.Fill(ds, "GroupsSizings");
I don't know what I am missing. Can anyone point out what is missing either in my Stored Procedure or my .Net code that is causing this to occur?