RE: sequences and order by

  • From: "Khedr, Waleed" <Waleed.Khedr@xxxxxxx>
  • To: <oracle-l@xxxxxxxxxxxxx>
  • Date: Thu, 6 May 2004 20:17:54 -0400

From Oracle 7 doc ( I knew it was not allowed since Oracle 8):

Using Sequence Values
You can use CURRVAL and NEXTVAL in these places:
. the SELECT list of a SELECT statement that is not contained in a
subquery, snapshot or view
. the SELECT list of a subquery in an INSERT statement
. the VALUES clause of an INSERT statement
. the SET clause of an UPDATE statement

You cannot use CURRVAL and NEXTVAL in these places:
. a subquery in a DELETE, SELECT, or UPDATE statement
. a view's query or snapshot's query
. a SELECT statement with the DISTINCT operator
. a SELECT statement with a GROUP BY or ORDER BY clause
. a SELECT statement that is combined with another SELECT statement with
the UNION, INTERSECT, or MINUS set operator
. the WHERE clause of a SELECT statement
. DEFAULT value of a column in a CREATE TABLE or ALTER TABLE statement
. the condition of a CHECK constraint

-----Original Message-----
From: david wendelken [mailto:davewendelken@xxxxxxxxxxxxx]
Sent: Thursday, May 06, 2004 7:34 PM
To: oracle-l@xxxxxxxxxxxxx
Subject: sequences and order by



I've been coding pl/sql for 16 years or so and just ran into something
today that surprised me.

I was doing a standard Insert into ... select ... from ... statement.

I had a sequence_name.nextval in the select clause and an order by
clause on the select statement.

Oracle wouldn't accept the use of the NEXTVAL with an ORDER BY.

Has it always been that way?

Have I really coded hundreds of complex programs and just never run into
that before?


----------------------------------------------------------------
Please see the official ORACLE-L FAQ: http://www.orafaq.com
----------------------------------------------------------------
To unsubscribe send email to:  oracle-l-request@xxxxxxxxxxxxx
put 'unsubscribe' in the subject line.
--
Archives are at //www.freelists.org/archives/oracle-l/
FAQ is at //www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------
----------------------------------------------------------------
Please see the official ORACLE-L FAQ: http://www.orafaq.com
----------------------------------------------------------------
To unsubscribe send email to:  oracle-l-request@xxxxxxxxxxxxx
put 'unsubscribe' in the subject line.
--
Archives are at //www.freelists.org/archives/oracle-l/
FAQ is at //www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------

Other related posts: