This content has been marked as final. Show 6 replies
Immjediately before you execute.. how many parameters does the command have, and what are the values?
No need to do this much code for getting value from function ,
just take values like this
Dim cnn As New Oracle.DataAccess.Client.OracleConnection("Data Source=OracleG;User Id=Scott;password=Tiger")
Dim cmd As New Oracle.DataAccess.Client.OracleCommand()
cmd.CommandType = CommandType.Text
Dim obj as object
Dim s as String
obj = cmd.ExecuteScalar("SELECT SaveData('Hello') FROM DUAL")
s = obj.ToString()
For some reason only knows to Larre, your returnvalue must be the FIRST parameter. Not sure for the logic, but it works.
So by simply switching your code to:
cmd.Parameters.Add("RS", Oracle.DataAccess.Client.OracleDbType.Varchar2, ParameterDirection.ReturnValue)
cmd.Parameters.Add("EN", Oracle.DataAccess.Client.OracleDbType.Varchar2, 100, "HHH", ParameterDirection.Input)
I am agree with kesler's opinion,Just do it.
Just fyi, here's the reason the returnvalue needs to be first. ODP constructs an anonymous block to execute the stored procedure, along the lines of the following:
begin :retval := myproc(:paramval);end;
and the default for ODP is to bind by position, rather than by name. So the fist parameter added needs to be the return value.
Hope it helps,
Thanks man... I was in a lot of troubles with this, and i would never imagine that the parameter must be the first one