Re: cursors as table sources - Mailing list pgsql-general

From Michael Fuhr
Subject Re: cursors as table sources
Date
Msg-id 20060111182430.GA86729@winnie.fuhr.org
Whole thread Raw
In response to cursors as table sources  ("Peter Filipov" <pfilipov@netissat.bg>)
Responses Re: cursors as table sources  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: cursors as table sources  (Will Glynn <wglynn@freedomhealthcare.org>)
List pgsql-general
On Wed, Jan 11, 2006 at 04:11:18PM +0200, Peter Filipov wrote:
> Is the idea to use cursors as table sources good?
> Do you plan to implement it in the future and if you plan will it be soon?

Do you mean the ability to use a cursor as one of the sources in
the FROM clause?  Something like the following non-working examples?

  DECLARE curs CURSOR FOR SELECT * FROM table1;
  SELECT * FROM table2, curs;

or

  DECLARE curs CURSOR FOR SELECT * FROM table1;
  SELECT * FROM table2, (FETCH ALL FROM curs) AS s;

As far as I know PostgreSQL doesn't allow anything like that;
somebody please correct me if I'm mistaken.  However, you could
write a set-returning function that takes a refcursor argument and
iterates through the cursor, returning each row, and use that
function in the FROM clause.  Whether that's a good idea or not is
something I haven't given much thought to.  Is there a reason you'd
want to use a cursor instead of, say, a view?

Are you just curious or is there a problem you're trying to solve?
If I've misunderstood what you're asking then please elaborate.

--
Michael Fuhr

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Connection specific information - Temporary table used
Next
From: Marcos
Date:
Subject: Create Produre for DROP row