Groups > Databases > Oracle for ASP.NET > Re: How to call a SQL function which returns a cursor using c#




How to call a SQL function which returns a cursor using c#

How to call a SQL function which returns a cursor using c#
Tue, 4 Mar 2008 01:20:48 +0000
Hi

i am new to .net. Can someone please advise how to call a SQL function which
returns a cursor using c#

i have tried to call using 
OracleCommand.CommandType = CommandType.StoredProcedure 
OracleParameter p_case_action_id = new
OracleParameter("@p_case_action_id", OracleDbType.Int32);
                    p_case_action_id.Direction = ParameterDirection.Input;
                    p_case_action_id.Value = intSourceID;
                    orlCmd5.Parameters.Add(p_case_action_id);

but it's throwing an exception saying invalid arguments or saying the function
name is invalid

i even tried to call the function  using CommandText rather than storedprocedure
and the result is same errors

Function
--------------
FUNCTION get_student_data(studentid IN NUMBER) RETURN case_cursor;

Thanks in advance
Sri
Post Reply
Re: How to call a SQL function which returns a cursor using c#
Tue, 4 Mar 2008 02:27:15 +0000
Hi Sri You can’t call the SQL function directly from .net code. SQL function
you can call with in the SQL statements or Stored Procedures. So, you change
your SQL function in to stored procedure.  And make your return type as output
parameter. And change your code like bellow OracleCommand.CommandType =
CommandType.StoredProcedure 
OracleParameter p_case_action_id = new
OracleParameter("@p_case_action_id",
OracleDbType.Int32);OracleParameter outPut = new
OracleParameter("o_disclsr_docs", DataAccess.DataType.Cursor,
ParameterDirection.Output);
                    p_case_action_id.Direction = ParameterDirection.Input;
                    p_case_action_id.Value = intSourceID;
                    orlCmd5.Parameters.Add(p_case_action_id);                   
 orlCmd5.Parameters.Add(outPut);   For more detail information  see the bellow
URLhttp://support.microsoft.com/kb/322160

 

 

With regards

Ganesan
Post Reply
Re: How to call a SQL function which returns a cursor using c#
Tue, 4 Mar 2008 10:58:36 +0000
Thanks for your reply. i found my solution at
http://p2p.wrox.com/topic.asp?TOPIC_ID=30294 Thanks again
Post Reply
about | contact