hello, this is a basic question. We have bought the 2.5 Pro version and I need to call a Postgres function using the Enterprise Library data access block. The function takes only input parameters, and returns a bool, such as:
IF devcount >= 1 THEN
RETURN TRUE;
ELSE
RAISE NOTICE '01';
RETURN FALSE;
END IF;
I can run the function and it workd fine in pgadmin. I've not been able to get a correct return value using ExecuteScalar, but I see this only works if you are doing a SELECT. What would the syntax look like to get a function value returned from a RETURN statement like this ? Thanks.
how to get a stored proc return value in Ent lib provider
Don't understand what the problem.
Choose CommandType=StoredProc for PgSqlCommand component.
And write the code:
Should return "True".
Choose CommandType=StoredProc for PgSqlCommand component.
And write the code:
Code: Select all
pgSqlConnection1.Open();
pgSqlCommand1.Parameters[0].Value = 1;
MessageBox.Show(pgSqlCommand1.ExecuteScalar().ToString());
Function declaration might look like the following:
Code: Select all
CREATE OR REPLACE FUNCTION test.devcount(count int4)
RETURNS bool AS
$BODY$
BEGIN
IF $1 >= 1 THEN
RETURN TRUE;
ELSE
RAISE NOTICE '01';
RETURN FALSE;
END IF;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION test.devcount(count int4) OWNER TO postgres;