title: Using Oracle.ManagedDataAccess.Client to return a value from a function to c#
body: <p>I have the following Function in Oracle:</p>
  
  <pre><code>FUNCTION return_test (p_id varchar2) RETURN VARCHAR2
  is
     p_return_val VARCHAR2 (500 CHAR) := 'test';
  begin  
     return p_return_val;
  end;
  </code></pre>
  
  <p>I'm trying to get the value into my c# code as follows:</p>
  
  <pre><code>var dbCommand = new OracleCommand();
  string retVal;
  string Function_query = "PKG_TEST.return_test";
  dbConnection = new OracleConnection(ConnString);
  dbConnection.Open();
  
  
  OracleParameterCollection dbParams = dbCommand.Parameters;
  dbParams.Add("p_return_val", OracleDbType.Varchar2, System.Data.ParameterDirection.ReturnValue);
  dbParams.Add("p_id", OracleDbType.Varchar2, "123", System.Data.ParameterDirection.Input); 
  
  OracleCommand cmd;
  OracleParameter dbAddParam;
  cmd = new OracleCommand(Function_query , dbConnection); 
  cmd.CommandType = CommandType.StoredProcedure;
  foreach (OracleParameter dbParam in dbParams)
  {
      dbAddParam = (OracleParameter)dbParam.Clone(); // clones all settings
      cmd.Parameters.Add(dbAddParam);
  }
  retVal = cmd.ExecuteScalar().tostring();
  </code></pre>
  
  <p>The Error while debugging is:</p>
  
  <blockquote>
    <p>{"ORA-06502: PL/SQL: numeric or value error: character string buffer
    too small\nORA-06512: at line 1"}</p>
  </blockquote>