ORA-06502: PL/SQL: numeric or value error: character string buffer too small


  • Hello

    I am running into "ORA-06502: PL/SQL: numeric or value error: character string buffer too small" and I managed to get around it by setting oParam.Size to length of command text instead of the parameter itself!?!

    The stored proc signature is

    TestId varchar2,
    bAllTestCleared OUT varchar2

    And my code/C# - yes first place I checked is that I have set parameter size of course:

    void SomeTest()
    IDbConnection oConn = null;
    IDbCommand oCmd = null;
    IDataParameter oParam = null;
    IDataParameter oOutParam = null;

    string strTestId = null;

    object oReturnValRaw = null;


    strTestId = Guid.NewGuid().ToString();

    oConn = DBUtil.GetDefaultDBConnection();

    oCmd = oConn.CreateCommand();
    oCmd.CommandText = "spXXXXX";
    oCmd.CommandType = System.Data.CommandType.StoredProcedure;

    oParam = oCmd.CreateParameter();
    oParam.Value = strTestId;
    oParam.ParameterName = ":TestId";
    oParam.DbType = DbType.String;
    ((OracleParameter) oParam).Size = strTestId.Length; // Also tried doubling length: Size = strTestId.Length*2. Actually, I solved the problem by setting - oParam.Size = oCmd.CommandText.Length - what the ____...? It worked, but I have no idea why!?
    oParam.Direction = ParameterDirection.Input;

    oOutParam = oCmd.CreateParameter();
    oOutParam.ParameterName = ":bAllTestCleared";
    oOutParam.DbType = DbType.String; // one character string, either: 'Y' or 'N'
    ((OracleParameter) oOutParam).Size = 1; 
    // Also tried doubling length: Size = 2
    oOutParam.Direction = ParameterDirection.Output;


    oReturnValRaw = oOutParam.Value;
    catch (Exception ex)
    } finally {...}

    Any suggestion? Is this a bug?


    My environment:
    1. I'm using ODP.NET BETA downloaded from

    The package includes Oracle Data Provider for .NET 2.0 Beta - from my app.config I have made sure I'm using the correct version by

    <qualifyAssembly partialName="Oracle.DataAccess" fullName="Oracle.DataAccess, Version=, Culture=neutral, PublicKeyToken=89b483f429c47342"/>

    2. Database: 11g Express
    • Edited by devvvy Monday, June 29, 2009 6:48 AM
    Monday, June 29, 2009 4:15 AM


All replies

  • You need to follow up on the Oracle forums for ODP.NET issues.
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Tuesday, June 30, 2009 9:39 PM
  • Thanks. I was struggling with the issue.Your solution helped.

    Defining the size of the oracle parameter , by first defining the string and getting its string length really worked.


                    Dim retStatusName As New OracleParameter
                    retStatusName.ParameterName = "pstatus_Name"
                    retStatusName.Value = statusName
                    retStatusName.DbType = DbType.String
                    'size issue
                    Dim tempString As String = "This is a temporary string to define the size of the string"
                    retStatusName.Size = tempString.Length
                    retStatusName.Direction = ParameterDirection.Output

    Note: give a sample string based on the size of your output string.

    Wednesday, March 11, 2015 6:58 PM