From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | Peter Filipov <pfilipov(at)netissat(dot)bg> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: cursors as table sources |
Date: | 2006-01-11 18:24:30 |
Message-ID: | 20060111182430.GA86729@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2006-01-11 18:38:58 | Re: cursors as table sources |
Previous Message | Marcos | 2006-01-11 17:13:01 | Concept about stored procedures |