I have an Oracle databases that has a stored procedure which accepts a string. This return is just a simple message of varchar2 type.
Can someone please tell me what I am doing wrong in the C# code below? - it fails on the ExecuteNonQuery()
Thanks in advance.
if (connection != null)
{
try
{
// Create the Oracle command (as Stored Procedure)
OracleCommand myCmd2 = new OracleCommand("INSERT_PID_XML",connection);
myCmd2.CommandType = CommandType.StoredProcedure;
// Pass parameters to the Stored Procedure
OracleParameter myParam1 = myCmd2.Parameters.Add("P_DATA",OracleDbType.Clob);
myParam1.Direction = ParameterDirection.Input;
myParam1.Value = xmldata;
OracleParameter myParam2 = myCmd2.Parameters.Add("P_ERROR_MSG",OracleDbType.Varchar2);
myParam2.Direction = ParameterDirection.Output;
// Execute command and return error code
myCmd2.ExecuteNonQuery();
string error = (string) myParam2.Value;
if (error != ""
{
return error;
}
else
{
return "0";
}
}
catch (Exception e)
{
return e.ToString();
}
finally
{
connection.Close();
}
}
else
{
return "3";
}
Can someone please tell me what I am doing wrong in the C# code below? - it fails on the ExecuteNonQuery()
Thanks in advance.
if (connection != null)
{
try
{
// Create the Oracle command (as Stored Procedure)
OracleCommand myCmd2 = new OracleCommand("INSERT_PID_XML",connection);
myCmd2.CommandType = CommandType.StoredProcedure;
// Pass parameters to the Stored Procedure
OracleParameter myParam1 = myCmd2.Parameters.Add("P_DATA",OracleDbType.Clob);
myParam1.Direction = ParameterDirection.Input;
myParam1.Value = xmldata;
OracleParameter myParam2 = myCmd2.Parameters.Add("P_ERROR_MSG",OracleDbType.Varchar2);
myParam2.Direction = ParameterDirection.Output;
// Execute command and return error code
myCmd2.ExecuteNonQuery();
string error = (string) myParam2.Value;
if (error != ""
{
return error;
}
else
{
return "0";
}
}
catch (Exception e)
{
return e.ToString();
}
finally
{
connection.Close();
}
}
else
{
return "3";
}