I am trying to execute some oracle pl/sql procedure with in and out parameters from # code on asp.net. I want to retrive the value from out parameter. but when I execute i am ge
It is working for me now. Mistake is I have declared a parameter "Id" as varchar2. but I didn't give any size to that. Now I have declared max size to the parameter and its working fine.
cmd_chk.Parameters.Add("id", OracleDbType.Varchar2,32767).Direction = ParameterDirection.Output;
Faced the same issue when declaring out put value as Varchar2. Adding a Size property to Parameter solved the issue.
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "function_name";
command.Parameters.Add(new OracleParameter
{
ParameterName = "result",
Size = 1,
Direction = ParameterDirection.ReturnValue,
OracleDbType = OracleDbType.Varchar2
});
Can you try with
anchored datatype like %type.
syntax :- tablename.colname%type.
you need to increase the size of u_id
u_id varchar2(4000);
The problem originates from using Char which is a fixed length string. Not sure where, but somewhere in your code you try to put a Char or varchar2 string of length N into a char of lengh M where M > N.
Another strage thing we RAN into related to this is with Oracle functions, for the special ParameterDirection.ReturnValue (*** all the rest of the ParameterDirection will work)
if you decalre it like bellow, directly in the constructor it DOSEN'T work:
cmd.Parameters.Add(new OracleParameter("myretval", OracleDbType.Long, 10, ParameterDirection.ReturnValue));
Result in error like:
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-01403: no data found
ORA-06512: at line 1
if you declare it like this it works:
OracleParameter retval = (new OracleParameter("myretval", OracleDbType.Long, 10);
retval.Direction = ParameterDirection.ReturnValue;
cmd.Parameters.Add(retval);