Обсуждение: INSERT/SELECT with ORDER BY

Поиск
Список
Период
Сортировка

INSERT/SELECT with ORDER BY

От
Bob Rivoir
Дата:
============================================================================

                        POSTGRESQL BUG REPORT TEMPLATE
============================================================================



Your name  :  Bob Rivoir
Your email address : rhr2@psu.edu


System Configuration
---------------------
  Architecture (example: Intel Pentium)   : AMD Athlon

  Operating System (example: Linux 2.0.26 ELF)  : OpenLinux eDesktop 2.4

  PostgreSQL version (example: PostgreSQL-7.0):   PostgreSQL-7.0.2

  Compiler used (example:  gcc 2.8.0)  : gcc egcs-1.1.2 release


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


Please describe a way to repeat the problem.   Please try to provide a
concise reproducible example, if at all possible:
----------------------------------------------------------------------





If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------

Re: INSERT/SELECT with ORDER BY

От
Stephan Szabo
Дата:
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@bigpanda.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

Re: INSERT/SELECT with ORDER BY

От
Bruce Momjian
Дата:
>
> 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.

Yes, added to TODO.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: INSERT/SELECT with ORDER BY

От
Dirk Lutzebaeck
Дата:
Stephan Szabo writes:
 >
 > 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@bigpanda.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


Is 7.1 able to do INSERT/SELECT with ORDER BY and LIMIT ?

Dirk