Re: Dynamic SQL in Function - Mailing list pgsql-general

From rwade@uci.edu
Subject Re: Dynamic SQL in Function
Date
Msg-id 0267f7a9a11abfb3907fcccc87faf7a0.squirrel@webmail.uci.edu
Whole thread Raw
In response to Re: Dynamic SQL in Function  (Merlin Moncure <mmoncure@gmail.com>)
Responses Re: Dynamic SQL in Function
Re: Dynamic SQL in Function
List pgsql-general
Is this possible without having to pass in the _ref parameter?

Thanks

Ryan

> On Wed, Apr 22, 2009 at 12:29 PM,  <rwade@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
>
>



pgsql-general by date:

Previous
From: Karsten Hilbert
Date:
Subject: Re: varchar vs. text + constraint/triggers was: Help request to improve function performance
Next
From: Dan Armbrust
Date:
Subject: recover corrupt DB?