Re: INSERT/SELECT with ORDER BY

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Bob Rivoir <rhr2(at)psu(dot)edu>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: INSERT/SELECT with ORDER BY
Date: 2000-08-18 18:23:39
Message-ID: Pine.BSF.4.10.10008181108020.2057-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


Unless I'm horribly misreading the spec, this is correct.
ORDER BY is used in reference to cursor definitions and
direct select statements, but is not part of query expressions
which is what the INSERT INTO references.

<insert statement> ::=
INSERT INTO <table name>
<insert columns and source>

<insert columns and source> ::=
[ <left paren> <insert column list> <right paren> ]
<query expression>
| DEFAULT VALUES

<insert column list> ::= <column name list>

But, this may be a useful extension to allow, at least with the
existance of LIMIT.

Stephan Szabo
sszabo(at)bigpanda(dot)com

On Thu, 17 Aug 2000, Bob Rivoir wrote:
>
> Please enter a FULL description of your problem:
> ------------------------------------------------
> I got the following error message when I tried to do an INSERT using
> SELECT ... ORDER BY:
>
> ERROR: ORDER BY is not allowed in INSERT/SELECT

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2000-08-19 02:59:16 Re: date bug (again)
Previous Message Michael Richards 2000-08-18 17:35:24 default timestamp of 'now'