ORA-06502: PL/SQL: numeric or value error: character string buffer too small exception from C# code
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 });
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 smallORA-01403: no data foundORA-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);