Error in executing Oracle Stored Procedure using C#
These modifications in your code worked for me:
using (connection){ Int32 id = 1; OracleCommand cmd = new OracleCommand("TESTP", connection); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("tempID", OracleDbType.Int32, ParameterDirection.Input).Value = id; cmd.Parameters.Add("tempName", OracleDbType.Varchar2, 200).Direction = ParameterDirection.Output; cmd.Parameters.Add("tempLName", OracleDbType.Varchar2, 200).Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); string FName = cmd.Parameters["tempName"].Value.ToString(); string LName = cmd.Parameters["tempLName"].Value.ToString();}
You could also add exception blocks in Oracle procedure to handle no_data_found exception and avoid ORA-01403
error, like here:
CREATE OR REPLACE PROCEDURE TESTP (tempID IN TESTTABLE.ID%Type, tempName out TESTTABLE.NAME%TYPE, tempLName out TESTTABLE.LNAME%TYPE) ASBEGIN select Name, LNAME Into tempName,tempLName from TestTable Where ID = tempID;EXCEPTION WHEN NO_DATA_FOUND THEN tempName := null; tempLName := null;END;
and add additional OUT parameter informing about success or failure and handle it in C# code.