P
Phil Lindsay
Hello,
can anyone confirm or deny that functions still work in ODP.NET
(running against an Oracle 9 db)? I am having trouble calling a
function, but I have no trouble calling a stored procedure. I've done
some digging around on the internet, and a lot of people seem to talk
about stored procedures, but no one talks about calling a function
using ODP.NET.
There are only 3 options for command type in the ODP.NET library...
CommandType.StoredProcedure, CommandType.TableDirect, CommandType.Text
I've tried using CommandType.Text and calling the Oracle function the
same way I've called it in VB6. The function I am trying to call
returns a varchar2 variable which represents the next available label
(the function searches for "gaps" in between numbers caused by
previously deleted entities) and returns the lowest available number
in VARCHAR format. My function appears to work (no exception is
thrown) but I get NULL returned to me when I call this function...
===== start of code sample ====
myCmd = new OracleCommand();
myCmd.CommandType = CommandType.Text;
myCmd.Parameters.Add("LocationLabel",
Oracle.DataAccess.Client.OracleDbType.Varchar2);
myCmd.Parameters["LocationLabel"].Value = myLoc.Label;
OracleParameter p2 = myCmd.Parameters.Add("StructureLabel",
Oracle.DataAccess.Client.OracleDbType.Varchar2);
p2.Direction = System.Data.ParameterDirection.ReturnValue;
myCmd.CommandText = "MyPackage.Func_GetNextStructureLabel";
myCmd.Connection = myCon;
myCmd.ExecuteNonQuery();
//this returns NULL??
NextLabel = p2.Value.ToString();
===== end of code sample ====
One of our web developers was also having trouble calling the function
in another case, and they solved this problem by converting the
function to a stored procedure... I am just wondering has the line
between function and stored procedure blurred to the point that
there's no difference now? (i.e. stored procedures have replaced
functions??)
Thanks for your input,
PL
can anyone confirm or deny that functions still work in ODP.NET
(running against an Oracle 9 db)? I am having trouble calling a
function, but I have no trouble calling a stored procedure. I've done
some digging around on the internet, and a lot of people seem to talk
about stored procedures, but no one talks about calling a function
using ODP.NET.
There are only 3 options for command type in the ODP.NET library...
CommandType.StoredProcedure, CommandType.TableDirect, CommandType.Text
I've tried using CommandType.Text and calling the Oracle function the
same way I've called it in VB6. The function I am trying to call
returns a varchar2 variable which represents the next available label
(the function searches for "gaps" in between numbers caused by
previously deleted entities) and returns the lowest available number
in VARCHAR format. My function appears to work (no exception is
thrown) but I get NULL returned to me when I call this function...
===== start of code sample ====
myCmd = new OracleCommand();
myCmd.CommandType = CommandType.Text;
myCmd.Parameters.Add("LocationLabel",
Oracle.DataAccess.Client.OracleDbType.Varchar2);
myCmd.Parameters["LocationLabel"].Value = myLoc.Label;
OracleParameter p2 = myCmd.Parameters.Add("StructureLabel",
Oracle.DataAccess.Client.OracleDbType.Varchar2);
p2.Direction = System.Data.ParameterDirection.ReturnValue;
myCmd.CommandText = "MyPackage.Func_GetNextStructureLabel";
myCmd.Connection = myCon;
myCmd.ExecuteNonQuery();
//this returns NULL??
NextLabel = p2.Value.ToString();
===== end of code sample ====
One of our web developers was also having trouble calling the function
in another case, and they solved this problem by converting the
function to a stored procedure... I am just wondering has the line
between function and stored procedure blurred to the point that
there's no difference now? (i.e. stored procedures have replaced
functions??)
Thanks for your input,
PL