...
The usage of a sequence is limited and it can be used only in few areas of PL/SQL and SQL coding. It also happens when you are using it wrong in an sql statement like: .NextVal() instead of .NextVal (notice the missing brackets)
The following are the cases where you can't use a sequence (in Oracle):
For a SELECT Statement:
- In a WHERE clause
- In a GROUP BY or ORDER BY clause
- In a DISTINCT clause
- Along with a UNION or INTERSECT or MINUS
- In a sub-query
Other areas:
- A sub-query of Update or Delete
- In a View or snapshot
- In a DEFAULT or CHECK Condition of a table definition
- Within a single SQL statement that uses CURRVAL or NEXTVAL, all referenced LONG columns, updated tables, and locked tables must be located on the same database.
...