Restrictions on sequence operators
NEXTVAL and CURRVAL are valid only in SQL
statements, not directly in SPL statements. (But SQL statements that
use NEXTVAL and CURRVAL can be used in SPL routines.)
The following restrictions apply to these operators in SQL statements:
- You must have Select privilege on the sequence.
- In a CREATE TABLE or ALTER TABLE statement, you cannot specify NEXTVAL or CURRVAL in
the following contexts:
- In the Default clause of a column definition
- In the definition of a check constraint.
- In a SELECT statement, you cannot specify NEXTVAL or CURRVAL in
the following contexts:
- In the projection list when the DISTINCT keyword is used
- In the WHERE, GROUP BY, or ORDER BY clauses
- In a subquery
- When the UNION operator combines SELECT statements.
- You also cannot specify NEXTVAL or CURRVAL in these
contexts:
- In fragmentation expressions
- In reference to a remote sequence object in another database.