| From: | rwade(at)uci(dot)edu |
|---|---|
| To: | "Merlin Moncure" <mmoncure(at)gmail(dot)com> |
| Cc: | rwade(at)uci(dot)edu, pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Dynamic SQL in Function |
| Date: | 2009-04-23 15:36:17 |
| Message-ID: | 0267f7a9a11abfb3907fcccc87faf7a0.squirrel@webmail.uci.edu |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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(at)uci(dot)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(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Willy-Bas Loos | 2009-04-23 15:44:43 | Re: pg_lsclusters error after pg_dropcluster |
| Previous Message | Dan Armbrust | 2009-04-23 15:30:27 | recover corrupt DB? |