Mr.Maze Mr.Maze - 1 year ago 98
SQL Question

Sequence next value in select statement

I would like to use the same sequence number across multiple select statements
in sql form to eventually use it as a PK insert in a table and tie multiple records together.

So far, I can only select the NEXTVAL from dual:


However, when I include the sequence into a multiple column select, I get sequence not allowed here error.

SELECT col1, co2, col3, (select TEST_SEQ.NEXTVAL) SEQ
FROM table;

Any help is greatly appreciated.

Answer Source

Don't use a sub-select:

SELECT col1, co2, col3, TEST_SEQ.NEXTVAL as SEQ
FROM table; 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download