Home » Infrastructure » Windows » Returning REF Cursor from PL/SQL Function problem! (Oracle 11g Release 2)
Returning REF Cursor from PL/SQL Function problem! [message #502305] Tue, 05 April 2011 13:53 Go to next message
aucrun
Messages: 114
Registered: February 2011
Senior Member
Hi,

I've seen several code samples that show how to return a REFCURSOR from a Stored Function, but when I try it with C# it gives me allways WRONG NUMBER OF ARGUMENTS or somehing like that.

I presently don't have my code in here, but it is something like this:

cmd.Parameters.add ("parRefCursor", dbresult.RefCursor, direction.Result);

I'm being able to use it as a OUT parameter, but I would like to have it as a RETURN value from a Function.

Is it possible?

Thanks!
Re: Returning REF Cursor from PL/SQL Function problem! [message #502306 is a reply to message #502305] Tue, 05 April 2011 13:55 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>Is it possible?
yes

It would be helpful if you followed Posting Guidelines - http://www.orafaq.com/forum/t/88153/0/
Re: Returning REF Cursor from PL/SQL Function problem! [message #502308 is a reply to message #502306] Tue, 05 April 2011 14:01 Go to previous messageGo to next message
aucrun
Messages: 114
Registered: February 2011
Senior Member
If it is possible, I would appreciate if some kind of help could be given.

As the Posting Guidelines, have I done some kind of error in my first post?
Re: Returning REF Cursor from PL/SQL Function problem! [message #502309 is a reply to message #502308] Tue, 05 April 2011 14:04 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>I'm being able to use it as a OUT parameter,
post COPY & PASTE that substantiates statement above
Re: Returning REF Cursor from PL/SQL Function problem! [message #502311 is a reply to message #502309] Tue, 05 April 2011 14:21 Go to previous message
aucrun
Messages: 114
Registered: February 2011
Senior Member
For the case of someone eles have this same problem, that might be a noob problem, it is necessary to place the ReturnValues Parameters befores the Input Parameters when creating the OracleCommand!

Samples below:
                OracleCommand cmd = new OracleCommand("calculateparentclassnodes_DEL3", con);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;

                OracleParameter pCode = new OracleParameter("iCode", OracleDbType.Varchar2, 50);
                pCode.Direction = System.Data.ParameterDirection.Input;
                pCode.Value = "77014000";

                OracleParameter pAgency = new OracleParameter("iAgency", OracleDbType.Varchar2);
                pAgency.Direction = System.Data.ParameterDirection.Input;
                pAgency.Value = "GPC";


                OracleParameter pResult = new OracleParameter("cur_testes", OracleDbType.RefCursor, System.Data.ParameterDirection.ReturnValue);
                cmd.Parameters.Add(pResult);
                cmd.Parameters.Add(pCode);
                cmd.Parameters.Add(pAgency);

Thanks!

[Updated on: Wed, 06 April 2011 07:31]

Report message to a moderator

Previous Topic: error in oracle 11gr2 in winxp sp3 and winserver 2003
Next Topic: Installed ODAC 11g ver Release 3 (11.2.0.2.1) - no tnsping utility
Goto Forum:
  


Current Time: Thu Apr 18 16:34:25 CDT 2024