snippetModerate
How to get the next value of sequence?
Viewed 0 times
thenextvaluesequencegethow
Problem
Could somebody tell what is wrong with obvious query below:
As a result I'm getting:
db2 => select next value for schema_name.sequence_name;As a result I'm getting:
SQL0104N An unexpected token "END-OF-STATEMENT" was found following
"schema_name.sequence_name". Expected tokens may include: "".
SQLSTATE=42601Solution
You need to select from something. Another option is:
As you noted you can also use
db2 => values next value for schema_name.sequence_name;As you noted you can also use
SYSIBM.SYSDUMMY1 or create a virtual table:db2 => select next value for schema_name.sequence_name from ( values 1 );Code Snippets
db2 => values next value for schema_name.sequence_name;db2 => select next value for schema_name.sequence_name from ( values 1 );Context
StackExchange Database Administrators Q#126852, answer score: 10
Revisions (0)
No revisions yet.