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]](FIGURE/ZU041975.GIF)
- 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]](FIGURE/ZU041976.GIF)
- 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]](FIGURE/ZU041977.GIF)
- 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]](FIGURE/ZU041978.GIF)
All Rights Reserved. Copyright (C) 2011, Hitachi, Ltd.