Home » SQL & PL/SQL » SQL & PL/SQL » sequences  () 1 Vote
sequences [message #199129] Fri, 20 October 2006 06:12 Go to next message
Messages: 63
Registered: May 2005

select my_seq.nextval,my_seq.nextval from dual

Iam getting an output like this

4022661 4022661

Should it not be

4022661 4022662

What should be done to get the above output?

Re: sequences [message #199148 is a reply to message #199129] Fri, 20 October 2006 10:03 Go to previous message
Mahesh Rajendran
Messages: 10677
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
Expected behaviour and already accounted in the Oracle documentation

The sequence number can also be referenced outermost SELECT of a query or subquery. For example:


As defined, the first reference to order_seq.NEXTVAL returns the value 1. Each subsequent statement that references order_seq.NEXTVAL generates the next sequence number (2, 3, 4,. . .). The pseudo-column NEXTVAL can be used to generate as many new sequence numbers as necessary. However, only a single sequence number can be generated for each row. In other words, if NEXTVAL is referenced more than once in a single statement, then the first reference generates the next number, and all subsequent references in the statement return the same number.

Previous Topic: Minus Question
Next Topic: About ORA-01031: insufficient privileges Error
Goto Forum:

Current Time: Fri Aug 18 19:03:58 CDT 2017

Total time taken to generate the page: 0.08294 seconds