Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to use sequence in a select statement with order by clause

Satyam ReddyApr 7 2015 — edited Apr 8 2015

Hi Team,

Please let me know if there is any way of using sequnce in a select statement with order by clause.

something like this :

Sequence Creation Script:

Create Sequence seq_emp

Minvalue 1 Maxvalue 999999999999999999999999999

INCREMENT BY 1 START WITH 2500 NOCACHE NOORDER NOCYCLE ;

Query having issue

select empno,ename,sal,hiredate,seq_emp.nextval

from emp order by hiredate;

The following is the error message :

ORA-02287: sequence number not allowed here

02287. 00000 -  "sequence number not allowed here"

*Cause:    The specified sequence number (CURRVAL or NEXTVAL) is inappropriate

           here in the statement.

*Action:   Remove the sequence number.

we have similar statement which we are using in our migration related procs.

Any help most welcome

Regards

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 6 2015
Added on Apr 7 2015
16 comments
10,891 views