1

Here is the simple stored procedure that returns a character string literal

PROCEDURE getUserValidateProfileValue (      
  outParam1 OUT VARCHAR2)
AS
BEGIN  
    SELECT 'testABC' into outParam1 from dual;
END getUserValidateProfileValue;

this runs OK in Toad. And following is how I call it from my C# app (note: I have several other procedures that get called using same connection, etc, which all work fine)

...
using (OracleCommand command = DaoHelper.GetOracleBoundByNameStoredProcedureCommand(conn, schema, pkg, "getUserValidateProfileValue"))
{
   command.Parameters.Add("outParam1", OracleDbType.Varchar2, 2000, ParameterDirection.Output);
   command.ExecuteNonQuery(); <<<---bombs out here
   s1 = command.Parameters["outParam1"].Value.ToString();
}

this bombs out at "command.ExecuteNonQuery();"

how to retrieve this output?

2 Answers 2

2

OK -- I found the fix -- you have to include the OracleCollectionType which in my case I set to None:

command.Parameters.Add("outParam1", OracleDbType.Varchar2, 2000, OracleCollectionType.None, ParameterDirection.Output);

Now my procedure works.

Sign up to request clarification or add additional context in comments.

Comments

0

Give this a try in place of the current parameter add and see if it helps at all?

command.Parameters.Add(new SqlParameter("outParam1", OracleDbType.Varchar2));

3 Comments

--it doesn't like "SqlParameter" -- getting red line.
Admittedly I haven't used this in a few months, do this rather: SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { s1 += reader[0].ToString(); }
The proc returns only one value, so a reader would be a little overkill. But I found a fix anyway -- have to include OracleCollectionType .None to the parameter arg list.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.