1

I'm getting this error while calling Oracle function

Input string was not in a correct format.

This is function

create or replace function abs.test_func(test_in in integer)
return integer
is
   test_out integer ;
BEGIN
test_out:=test_in;
RETURN test_out;
END;

this is c# code

    using (var cmd = new OracleCommand("abs.test_func", conn1))
     {
     cmd.CommandType = CommandType.StoredProcedure;
     cmd.Parameters.Add(new OracleParameter("test_in", OracleDbType.Int64, test_in, ParameterDirection.Input));
     OracleParameter test_out = new OracleParameter("test_out", OracleDbType.Int64);
     test_out.Direction = ParameterDirection.ReturnValue;
     cmd.Parameters.Add(test_out);
     cmd.ExecuteNonQuery();
     JsonResponse.Result = Int32.Parse(test_out.Value.ToString());

I don't know wha I'm doing wrong, i wrote this function specially for testing purposes. It's very simple: 1 variable inputs 1 variable outputs as a function return. that's all. What else can be done here to get it working?

David
  • 4,332
  • 13
  • 54
  • 93
  • that's the complete error? What is the ORA- number? – OldProgrammer Aug 28 '20 at 19:43
  • that's my catch in c# "Oracle ERROR: " + exc.Message, which means problem rises on he c# side. pay no atantion to word Oracle ERROR. It's just my wriings... – David Aug 28 '20 at 20:01
  • As explained in your earlier question (https://stackoverflow.com/questions/63637471/oracle-function-compiles-successfully-but-throws-error-ora-06550-is-not-a-proce), you have written a _function_, but you are treating it like a _procedure_. A _function_ is _not_ a _stored procedure_; it is not called or used like a procedure; – EdStevens Aug 28 '20 at 20:16
  • thank you sir, I already found answer to my problem and posted solution. – David Aug 28 '20 at 20:23

1 Answers1

1

This Helped

cmd.Parameters.Add(new OracleParameter("test_out", OracleDbType.Int64, ParameterDirection.ReturnValue));

cmd.ExecuteNonQuery();
JsonResponse.Result = Int32.Parse(cmd.Parameters[0].Value.ToString());
David
  • 4,332
  • 13
  • 54
  • 93