Re: WITH HOLD ref cursors for plpgsql

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Daniel Wood <dwood(at)salesforce(dot)com>
Cc: "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: WITH HOLD ref cursors for plpgsql
Date: 2013-02-20 08:46:44
Message-ID: 24040.1361350004@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Daniel Wood <dwood(at)salesforce(dot)com> writes:
> So how does one create a "WITH HOLD ref cursor for plpgsql"?

You don't --- as the previous thread mentioned, there doesn't seem
to be a lot of use-case for that, and it goes against plpgsql's
model of cursors as essentially being local variables of functions.

If you're really feeling desperate to use plpgsql to create a cursor
that will be used later by some calling application, you could probably
do EXECUTE 'DECLARE c CURSOR WITH HOLD FOR SELECT ...'. But it's not
immediately clear to me why that's better than letting the calling
application do the DECLARE for itself.

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Paul Smith 2013-02-20 13:50:12 minimum hardware requirements for small postgres db
Previous Message Sergey Konoplev 2013-02-20 05:03:55 Re: Return table and integer value