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