Use CURRVAL and NEXTVAL in a statement
- Last Updated: February 11, 2026
- 1 minute read
- OpenEdge
- Version 13.0
- Documentation
When you create a sequence, you can define its initial
value and the increment between its values. The first reference
to NEXTVAL returns the sequence's initial value.
Subsequent references to NEXTVAL increment to the
sequence value by the defined increment and return the new value.
Any reference to CURRVAL always returns the sequence's
current value, which is the value returned by the last reference
to NEXTVAL. Therefore, a statement that contains multiple
references to sequence_name.NEXTVAL will
return the same value for each reference of sequence_name.NEXTVAL.
Example: INSERT statement using NEXTVAL
The following example uses NEXTVAL to assign
a new customer number into a customer table.
|
Example: SELECT statement using CURRVAL
To find the value entered in the customer table of the preceding example, use the following statement:
|