Nonstop Database, HiRDB Version 9 UAP Development Guide

[Contents][Index][Back][Next]

4.19.5 Examples

For these examples, you specify the NEXT VALUE expression in a selection expression in a query expression in the INSERT statement, an insertion value in the INSERT statement, or an update value in the UPDATE statement. If you specify the NEXT VALUE expression more than once for the same row using the same sequence generator, the NEXT VALUE expressions all return the same value.

Examples of the NEXT VALUE expression are presented below. These examples use sequence generator SEQ1 that was defined in 4.19.2 Defining a sequence generator.

Example:
If the NEXT VALUE expression is executed before any sequence number has been acquired from sequence generator SEQ1, the sequence generator's start value (10) is returned.
[Figure]

Example:
If two or more NEXT VALUE expressions with the same sequence generator specified are specified for the same row, they all return the same value (20).
[Figure]

Example:
If two or more NEXT VALUE expressions with the same sequence generator specified are specified for the same row for a table that contains repetition columns, they all return the same value (30).
[Figure]

Example:
If the NEXT VALUE expression is specified when the current value of sequence generator SEQ1 is the maximum value (990), the value immediately following the complete cycle (10) is returned.
[Figure]