On Wed, Apr 22, 2009 at 12:29 PM,  <rw...@uci.edu> wrote:
> If I have built a dynamic sql statement in a function, how do i return it
> as a ref cursor?

CREATE FUNCTION reffunc(_ref) RETURNS refcursor AS
$$
BEGIN
    OPEN _ref FOR execute 'SELECT * from foo';
    RETURN _ref;
END;
$$ LANGUAGE plpgsql;

BEGIN;
SELECT reffunc('funccursor');
FETCH ALL IN funccursor;
COMMIT;

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to