David
David

Reputation: 4518

Input string was not in a correct format while calling oracle function from c#

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?

Upvotes: 1

Views: 434

Answers (1)

David
David

Reputation: 4518

This Helped

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

cmd.ExecuteNonQuery();
JsonResponse.Result = Int32.Parse(cmd.Parameters[0].Value.ToString());

Upvotes: 1

Related Questions