Get values from sequences
After you establish a sequence, you can use the NEXT VALUE FOR
and the NEXT <integer expression> VALUES FOR statement to retrieve
sequence values.
- The NEXT VALUE FOR statement returns the next available value.
- The NEXT <integer expression> VALUES FOR statement returns the first of a set of contiguous values for the sequence.
Note: Sequences generate unique numbers, but the next
number the system generates for any sequence might not be the next
number that you would expect for that progression. There might or
might not be a gap between the last sequence number that is generated
and the next. For example, you are using a sequence where 2 is the
common difference, as in “3, 5, 7, 9.” The next number that you would
expect is 11, but the system might return the number 17. This behavior
is expected behavior for sequencing.