I have a procedure in oracle having input fields varchar2 and number. I am adding parameters from my .Net code using Oracle.DataAccess.dll. I am getting an exception like
ORA-06502: PL/SQL: numeric or value error: character to number conversion error\nORA-06512: at line 1
If I run procedure directly from oracle sql developer, it works fine.
code:-
OracleCommand cmd = (OracleCommand)_dbFactory.CreateCommand();
try
{
cmd.Connection = (OracleConnection)_conOracle;
_conOracle.Open();
cmd.CommandText = "SERVICE_STATUS";
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Parameters.Clear();
cmd.Parameters.Add("PANUMBER", OracleDbType.Int32).Value = 10;
cmd.Parameters.Add("PA_LINK", OracleDbType.Varchar2).Value = "Test";
cmd.Parameters.Add("PO_MSG", OracleDbType.Varchar2, 4000).Direction = System.Data.ParameterDirection.Output;
try
{
cmd.ExecuteScalar();
}
catch(Exception ex1) {
log.Debug("Exception ex1 "+ ex1.Message+" inner--"+ex1.InnerException);
}
string isValid = cmd.Parameters["PO_MSG"].Value.ToString();
if (isValid == "SUCCESS")
return true;
else
return false;
}
catch (Exception ex)
{
throw ex;
}
finally
{
_conOracle.Close();
}
procedure
create or replace
PROCEDURE SERVICE_STATUS( panumber number, pa_link varchar2 default NULL, po_msg OUT VARCHAR2 )
is
BEGIN
--logic comes here
END;
--logic comes here
but assignpo_msg := "Some Test Message";
? – Dmitry BychenkoOracleDbType.Int32
toOracleDbType.Decimal
- Oracle maps a NUMBER without precision to a .NET Decimal not an integer - Also you should be callingExecuteNonQuery
... – Dominic Cotton