[ad_1]
I’m trying to return a query on true inside an if statement with postgreSQL. It’s been a while but I’m sure I am on the right track.
Here is what I have.
DO $$
BEGIN
IF (SELECT COUNT(1) FROM uploads WHERE uploaded = true AND ele="aba" ) >= 1 THEN
RETURN QUERY ( SELECT * FROM uploads WHERE uploaded = true AND state="aba" );
ELSE
RAISE NOTICE 'false';
END IF;
END $$;
I’ve also tried perform without any luck. I get the following error ERROR: cannot use RETURN QUERY in a non-SETOF function
. Now I know that this means it is looking for a scalar and not multiple rows. So I’m guessing return query is not the right function to be using?
[ad_2]