title: Oracle ORA-06502 PL/SQL: numeric or value error: character to number conversion error
body: <p>I know there is a lot of these things, and I've gone through basically all of them, and I can't seem to find an answer to my problem. </p>
  
  <p>I have a package with a function as follows:</p>
  
  <pre><code>FUNCTION AFunction(AString1 varchar2, ANumber NUMBER, AString2 VARCHAR2) RETURN VARCHAR2 AS
  </code></pre>
  
  <p>In <code>C#</code> I execute it like</p>
  
  <pre><code>using (var cmd = new OracleCommand("SCHEMA.MYPACKAGE.AFunction", conn))
  {
      cmd.CommandType = CommandType.StoredProcedure;
      cmd.Parameters.Add("AString1", "Param1");
      cmd.Parameters.Add("ANumber", 123);
      cmd.Parameters.Add("AString2", "Param2");
      cmd.Parameters.Add("ReturnValue", OracleDbType.Varchar2).Direction = ParameterDirection.ReturnValue;
  
      cmd.ExecuteNonQuery();
  }
  </code></pre>
  
  <p>Additional information: ORA-06502: PL/SQL: numeric or value error: character to number conversion error
  ORA-06512: at line 1</p>
  
  <p>In Debug I can see that <code>Param1</code>, <code>Param2</code> and <code>ReturnValue</code> is <code>varchar2</code> and <code>ANumber</code> is Int32. Even if I change ANumber to Int64, it still does not work, and I'm not sure why I get this error, because everything seem fine. Can anybody maybe point out to me if I made a silly mistake?</p>
  
  <p>If I execute this in toad it works without a problem.</p>
  
  <pre><code>DECLARE 
    RetVal VARCHAR2(200);
    PARAM1 VARCHAR2(4000);
    PARAM2 VARCHAR2(100);
    ANUMBER NUMBER;
  
  BEGIN 
    PARAM1 := 'AParam1';
    ANUMBER := 123;
    PARAM2 := 'AParam2';
  
    RetVal := SCHEMA.MYPACKAGE.AFunction ( PARAM1, ANUMBER, PARAM2 );
    COMMIT; 
  END;
  </code></pre>