title: Unable to execute oracle function from c#
body: <p>I'm having problems executing a function in one of my oracle packages from c#. The following is my code for opening the connection and executing the function:</p>
  
  <pre><code>Decimal firstID = Decimal.Parse("2453699");// This values are just for testing
  string secondID = "12345"; 
  Decimal sec = Decimal.Parse("1"); 
  string estatus = "TEXT"; 
  
  OracleConnection con = new OracleConnection();
  con.ConnectionString = "User Id=user;Password=the_pass;Data Source=Data_Source";
  
  con.Open();
  string sql = "Package.F_FUNCTION_1";
  OracleCommand com = new OracleCommand(sql, con);
  com.CommandType = System.Data.CommandType.StoredProcedure;
  
  com.Parameters.Add("returnVal", OracleDbType.Varchar2, 32767);
  com.Parameters["returnVal"].Direction = System.Data.ParameterDirection.ReturnValue;
  
  com.Parameters.Add("v_firstID",OracleDbType.Decimal,10);
  com.Parameters.Add("v_secondID", OracleDbType.Varchar2,200);
  com.Parameters.Add("p_sec", OracleDbType.Decimal, 3);
  com.Parameters.Add("p_estatus", OracleDbType.Varchar2,50);
  
  com.Parameters["v_firstID"].Value = firstID;
  com.Parameters["v_secondID"].Value = secondID;
  com.Parameters["p_sec"].Value = sec;
  com.Parameters["p_estatus"].Value = estatus;
  
  com.ExecuteNonQuery();
  string val = com.Parameters["returnVal"].Value.ToString();
  con.Close();
  </code></pre>
  
  <p>And the following is the function in my package, which needs to call a second function in the same package:</p>
  
  <pre><code>FUNCTION F_FUNCTION_1(v_firstID IN NUMBER,
                        v_secondID IN VARCHAR2
                        ,p_sec    IN NUMBER DEFAULT NULL
                        ,p_estatus IN VARCHAR2 DEFAULT NULL)
  RETURN VARCHAR2 AS
  v_Return VARCHAR2(200) := '';
  secuencia    VARCHAR2(1000) := null; 
  secc        VARCHAR2(1000) := NULL;
  BEGIN
  
  -- Some validations 
  
  v_Return := Package.F_FUNCTION_2(
  v_secondID =&gt; v_secondID,
  P_SEC =&gt; p_sec,
  P_ESTATUS =&gt; p_estatus
  );
  
  return v_Return;
  END F_FUNCTION_1;
  
  FUNCTION F_FUNCTION_2(v_secondID IN VARCHAR2
                            ,p_sec    IN NUMBER DEFAULT NULL
                            ,p_estatus IN VARCHAR2 DEFAULT NULL)
  RETURN VARCHAR2 AS
   --some variables
   v_URL          VARCHAR2(500)    := NULL;
  BEGIN
  
    --A lot of code here that works
  
    RETURN v_URL;
  END F_FUNCTION_2;
  </code></pre>
  
  <p>The problem is: when i run this code, i get the error:</p>
  
  <p>ORA-01460: unimplemented or unreasonable conversion requested</p>
  
  <p>I suppose it is related to the parameters types. I'v tried changing types, using ExecuteScalar instead of ExecuteNonQuery, changing the syntax of the parameters addition to the command... but they didn't work.</p>
  
  <p>I know it's easy but I have a brain lock now.</p>
  
  <p>Hope someone can help.</p>