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?

4
  • that's the complete error? What is the ORA- number? Commented Aug 28, 2020 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... Commented Aug 28, 2020 at 20:01
  • As explained in your earlier question (stackoverflow.com/questions/63637471/…), 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; Commented Aug 28, 2020 at 20:16
  • thank you sir, I already found answer to my problem and posted solution. Commented Aug 28, 2020 at 20:23

1 Answer 1

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());
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.