ORA-06502: PL/SQL: numeric or value error: character string buffer too small exception from C# code

前端 未结 6 2207
暖寄归人
暖寄归人 2021-02-20 03:33

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

相关标签:
6条回答
  • 2021-02-20 03:47

    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;
    
    0 讨论(0)
  • 2021-02-20 03:47

    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
                            });
    
    0 讨论(0)
  • 2021-02-20 03:47

    Can you try with anchored datatype like %type.
    syntax :- tablename.colname%type.

    0 讨论(0)
  • 2021-02-20 03:55

    you need to increase the size of u_id

    u_id varchar2(4000);
    
    0 讨论(0)
  • 2021-02-20 03:57

    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.

    0 讨论(0)
  • 2021-02-20 03:59

    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);
    
    0 讨论(0)
提交回复
热议问题