FETCH FIRST

Started by Simon Riggsalmost 18 years ago5 messages
#1Simon Riggs
simon@2ndquadrant.com

SQL200n specifies a new command similar to our LIMIT

FETCH { FIRST | NEXT } n { ROW | ROWS } ONLY

and also that the OFFSET command can have an optional suffix

{ ROW | ROWS }

Seems like a % project for the TODO list

--
Simon Riggs
2ndQuadrant http://www.2ndQuadrant.com

PostgreSQL UK 2008 Conference: http://www.postgresql.org.uk

#2Bruce Momjian
bruce@momjian.us
In reply to: Simon Riggs (#1)
Re: FETCH FIRST

Simon Riggs wrote:

SQL200n specifies a new command similar to our LIMIT

FETCH { FIRST | NEXT } n { ROW | ROWS } ONLY

and also that the OFFSET command can have an optional suffix

{ ROW | ROWS }

Seems like a % project for the TODO list

Where does this FETCH appear in a SELECT?

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://postgres.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#3Simon Riggs
simon@2ndquadrant.com
In reply to: Bruce Momjian (#2)
Re: FETCH FIRST

On Tue, 2008-03-25 at 10:45 -0400, Bruce Momjian wrote:

Simon Riggs wrote:

SQL200n specifies a new command similar to our LIMIT

FETCH { FIRST | NEXT } n { ROW | ROWS } ONLY

and also that the OFFSET command can have an optional suffix

{ ROW | ROWS }

Seems like a % project for the TODO list

Where does this FETCH appear in a SELECT?

It's supposed to go *after* the OFFSET clause in a query, but making it
a simple synonym for LIMIT seems most sensible.

It's also allowed as part of the WITH clause (that we don't yet have).

--
Simon Riggs
2ndQuadrant http://www.2ndQuadrant.com

PostgreSQL UK 2008 Conference: http://www.postgresql.org.uk

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Simon Riggs (#3)
Re: FETCH FIRST

Simon Riggs <simon@2ndquadrant.com> writes:

On Tue, 2008-03-25 at 10:45 -0400, Bruce Momjian wrote:

Where does this FETCH appear in a SELECT?

It's supposed to go *after* the OFFSET clause in a query, but making it
a simple synonym for LIMIT seems most sensible.

Huh? OFFSET isn't in standard SQL either. Are you sure you're not
confusing FETCH-from-a-cursor with SELECT?

regards, tom lane

#5Simon Riggs
simon@2ndquadrant.com
In reply to: Tom Lane (#4)
Re: FETCH FIRST

On Tue, 2008-03-25 at 11:47 -0400, Tom Lane wrote:

Simon Riggs <simon@2ndquadrant.com> writes:

On Tue, 2008-03-25 at 10:45 -0400, Bruce Momjian wrote:

Where does this FETCH appear in a SELECT?

It's supposed to go *after* the OFFSET clause in a query, but making it
a simple synonym for LIMIT seems most sensible.

Huh? OFFSET isn't in standard SQL either.

Tis now.

Are you sure you're not
confusing FETCH-from-a-cursor with SELECT?

Quite sure.

--
Simon Riggs
2ndQuadrant http://www.2ndQuadrant.com

PostgreSQL UK 2008 Conference: http://www.postgresql.org.uk