oracle functions called from c# code
Hi, guys,
as stated in the subject, I got some pl/sql - functions at an oracle database. that I should start.
I do, of course, know, how to call a stored procedure or commit commands directly, but I really got no idea, how to use a function.
I can neither find information on this subject at MSDN nor elsewhere.
I also tried several drivers, but neither Microsoft Oracle Driver nor ODBC Driver made me happy.
Any idea would be very appriciated from my side, as I´m quite stuck, and the work is urgent, as every in this job.
Thank you,
Gilthanas
ramesh pPosted Apr 22, 2009, 2:08 AM
Try this:
DataTable dt = new DataTable();
OracleConnection Conn = new OracleConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
OracleCommand DbComm = new OracleCommand("SCHEMA.MYFUNCTION", Conn);
DbComm.CommandType = CommandType.StoredProcedure;
OracleParameter inVar = new OracleParameter("VAR", OracleType.VarChar);
inVar.Direction = ParameterDirection.Input;
inVar.Value = "999";
DbComm.Parameters.Add(inVar);
DbComm.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.ReturnValue;
Conn.Open();
OracleDataReader reader = DbComm.ExecuteReader();
dt.Load(reader);
reader.Close();
Conn.Close();