Peter Eisentraut wrote: > > CREATE PROCEDURE test() > > LANGUAGE plpgsql > > AS $$ > > RETURN QUERY EXECUTE 'SELECT 1 AS col1, 2 AS col2'; > > END; > > $$; > > > > Or is that not possible or not desirable? > > RETURN means the execution ends there, so how would you return multiple > result sets?
RETURN alone yes, but RETURN QUERY continues the execution, appending rows to the single result set of the function. In the case of a procedure, I guess each RETURN QUERY could generate an independant result set. > But maybe you don't want to return all those results, so you'd need a > way to designate which ones, e.g., > > AS $$ > SELECT set_config('something', 'value'); > SELECT * FROM interesting_table; -- return only this one > SELECT set_config('something', 'oldvalue'); > $$; Yes, in that case, lacking PERFORM in SQL, nothing simple comes to mind on how to return certain results and not others. But if it was in an SQL function, it wouldn't return the rows of "interesting_table" either. I think it would be justified to say to just use plpgsql for that kind of sequence. Best regards, -- Daniel Vérité PostgreSQL-powered mailer: http://www.manitou-mail.org Twitter: @DanielVerite -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers