Hi guys, I get a test procedure with 2 output parameters and do nothing:
CREATE OR REPLACE PACKAGE BODY p_parameters_test AS
PROCEDURE p_null_output_basetype(p1 OUT NUMBER,p2 OUT VARCHAR2)
AS
BEGIN
DBMS_OUTPUT.PUT_LINE('DO NOTHING');
END p_null_output_basetype;
END;
And I have below C# code:
cmd.CommandText = "p_parameters_test.p_null_output_basetype";
OracleParameter p1 = new OracleParameter("p1", OracleDbType.Decimal, System.Data.ParameterDirection.Output);
OracleParameter p2 = new OracleParameter("p2", OracleDbType.Varchar2, System.Data.ParameterDirection.Output);
cmd.Parameters.Add(p1);
cmd.Parameters.Add(p2);
try
{
conn.Open();
cmd.ExecuteNonQuery();
//
if (p1.Value==null)
{
Console.WriteLine("p1.Value==null");
}
else if (Convert.IsDBNull(p1.Value))
{
Console.WriteLine("Convert.IsDBNull(p1.Value)");
}
else
{
Console.WriteLine("p1 else "+p1.Value);
}
//
if (p2.Value==null)
{
Console.WriteLine("p2.Value==null");
}
else if (Convert.IsDBNull(p2.Value))
{
Console.WriteLine("Convert.IsDBNull(p2.Value)");
}
else
{
Console.WriteLine("p2 else "+p2.Value);
}
//
Console.WriteLine("finished");
}
catch......
The output of it is:
p1 else null
p2 else null
Does anyone have any idea why it always goes to the 'else' of the condition-branching, and how can I check if the output parameter is null?
Thanks in advance.