Sushant Bagul

Sushant Bagul

  • NA
  • 16
  • 5.5k

Getting error on output parameter.

Nov 20 2021 6:22 AM

I have done POC on Visual Studio 2017 .Net Framework 4.5.2 with DB Oracle 19c (Version 19.3) as ODP.Net we have used dll named as Oracle.DataAccess.Client.

Getting below error at C# side

ORA-06502 : PL/SQL: Numeric or Value error : Character string buffer too small.

Stored Procedure

Create or Replace Procedure POC_Test(p_message Out Varchar2)
As
Begin
    p_Message := 'XYZ'; 
End POC_Test;

//C# Code

using System;
Using Oracle.DataAcess.Client;

class DataBasePOC {
  static void Main() 
  {
    OracleConnection connection = new OracleConnection("DataSource=POC_Database;User Id=User1;Password=PQR123");
    OracleCommand cmd=new OracleCommand(); 
    connection.Open();
    cmd.CommandText="POC_Test";
    cmd.CommandType=CommandType.StoredProcedure;
    cmd.Parameters.Add("p_message", OracleDbType.Varchar2, "", ParameterDirection.Output);  
    OracleDataAdaptor da= new OracleDataAdaptor();
    da.SelectCommand=cmd;  
    DataTable dt= new DataTable();
    da.Fill(dt);
    connection.Close();  
  }
}

 


Answers (2)