plpgsql RETURN QUERY EXECUTE

Started by Pavel Stehuleover 18 years ago2 messagespatches
Jump to latest
#1Pavel Stehule
pavel.stehule@gmail.com

Hello

This patch allows dynamic queries in RETURN QUERY statement.

http://archives.postgresql.org/pgsql-hackers/2008-02/msg01180.php

Sample:

CREATE OR REPLACE FUNCTION test(tab varchar, b integer)
RETURNS SETOF integer AS $$
BEGIN
RETURN QUERY
EXECUTE 'SELECT a FROM ' || tab 'WHERE b = $1'
USING b;
RETURN;
END;
$$ LANGUAGE plpgsql;

Regards
Pavel Stehule

Attachments:

return_query_execute.difftext/x-patch; name=return_query_execute.diffDownload+233-121
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Pavel Stehule (#1)
Re: plpgsql RETURN QUERY EXECUTE

"Pavel Stehule" <pavel.stehule@gmail.com> writes:

This patch allows dynamic queries in RETURN QUERY statement.
http://archives.postgresql.org/pgsql-hackers/2008-02/msg01180.php

Applied, thanks.

regards, tom lane