Re: FETCH in subqueries or CTEs - Mailing list pgsql-general

From Craig Ringer
Subject Re: FETCH in subqueries or CTEs
Date
Msg-id 50375D66.2070802@ringerc.id.au
Whole thread Raw
In response to Re: FETCH in subqueries or CTEs  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: FETCH in subqueries or CTEs  (Pavel Stehule <pavel.stehule@gmail.com>)
Re: FETCH in subqueries or CTEs  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On 08/24/2012 12:34 PM, Pavel Stehule wrote:

> you can't mix planned and unplanned statements together - think about
> stored plans every time

Thanks Pavel and Jeff.

I can't say I fully understand the arguments, but I'll take it that
accepting cursors in CTEs or subqueries wouldn't make sense. I guess the
main issue really is that you'd have to materialize them anyway to avoid
issues with multiple scans, so there's little point having a cursor.

I didn't find a reasonable way to simply fetch a cursor into a (possibly
temporary) table, like:

INSERT INTO sometable FETCH ALL FROM somecursor;

... which could be handy with PL/PgSQL functions that return multiple
refcursors. It only seems to be possible via a PL/PgSQL wrapper that
loops over the cursor and returns a rowset.

--
Craig Ringer


pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: Rules, Windows and ORDER BY
Next
From: "SUNDAY A. OLUTAYO"
Date:
Subject: Re: Windows SIngle Sign On - LINUX Server