FETCH in subqueries or CTEs

From: Craig Ringer <ringerc(at)ringerc(dot)id(dot)au>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: FETCH in subqueries or CTEs
Date: 2012-08-24 01:35:34
Message-ID: 5036DA66.1060409@ringerc.id.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all

I've noticed that FETCH doesn't seem to be supported in subqueries or in
CTEs.

Is there a specific reason for that, beyond "nobody's needed it and
implemented it"? I'm not complaining at all, merely curious.

A toy example:

DECLARE somecursor CURSOR FOR SELECT generate_series(1,1000)
SELECT * FROM ( FETCH ALL FROM somecursor ) x;

produces:

ERROR: syntax error at or near "FETCH"
LINE 1: SELECT * FROM ( FETCH ALL FROM somecursor ) x;
^
Same with a CTE:

WITH x AS ( FETCH ALL FROM somecursor ) SELECT * FROM x;

ERROR: syntax error at or near "FETCH"
LINE 1: WITH x AS ( FETCH ALL FROM somecursor ) SELECT * FROM x;

--
Craig Ringer

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Chris Travers 2012-08-24 01:44:19 Re: Some thoughts on table inheritance (which is uniquely awesome on PostgreSQL)
Previous Message Jeff Janes 2012-08-24 00:56:37 Re: At what point does a big table start becoming too big?