0

I have a stored procedure in PostgreSQL:

CREATE OR REPLACE FUNCTION dosmth()
RETURNS boolean AS
$BODY$
BEGIN

RETURN FALSE;

 END;
 $BODY$
 LANGUAGE 'plpgsql' VOLATILE

From ado.net I need to retrieve the return value. I try to do the following:

   DbCommand cmd = DBTemplate.CreateStoredProcedureCommand(dbConnection, "dosmth");

   cmd.Parameters.Add(DBTemplate.CreateParameter(System.Data.DbType.Boolean,
                "@RETURN_VALUE", System.Data.ParameterDirection.ReturnValue));

   DBTemplate.ExecuteNonQuery(cmd);
   Boolean bl = Convert.ToBoolean(cmd.Parameters["@RETURN_VALUE"].Value);

Unfortunately this does not work telling me that the type DBNull cannot be converted to Boolean.
Any ideas?

1 Answer 1

1

Try using ExecuteScalar instead of ExecuteNonQuery. I seem to recall that ExecuteNonQuery doesn't return a result either.

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

Comments

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.