Accessing and incrementing sequences
- Last Updated: January 17, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
The following figure lists ABL statements and functions you can use to access and increment sequence values.
| Statement or function | Description |
|---|---|
CURRENT–VALUE function |
Returns the current value of a sequence identified at compile time. |
DYNAMIC–CURRENT–VALUE function |
Returns the current value of a sequence identified at run time |
NEXT–VALUE function |
Increments and returns the incremented value for a sequence identified at compile time |
DYNAMIC–NEXT–VALUE function |
Increments and returns the incremented value for a sequence identified at run time |
CURRENT–VALUE statement |
Sets a new current value for a sequence identified at compile time |
DYNAMIC–CURRENT–VALUE statement |
Sets a new current value for a sequence identified at run time |
Whenever a CURRENT–VALUE statement
or NEXT–VALUE function changes the value of a sequence, the
new value persists in the database where the sequence is defined
until it is changed again, or the sequence is deleted from the database.
The basic sequence statements and functions have the following syntax:
Syntax
|
Syntax
|
- sequence-name
- An identifier that specifies the name of a sequence defined in the Data Dictionary. Note that a sequence can have the same name as a database field, but they are distinct entities.
- logical-dbname
- An identifier that specifies the logical name of the database in which the sequence is defined. The database must be connected. You can omit this parameter only if you have a single database connected. Otherwise, you must specify the database in which the sequence is defined.
- expression
- An expression that evaluates to an integer value. The
CURRENT–VALUEstatement assigns the value of expression to the specified sequence. The value of expression must be within the range defined for the specified sequence. - tenant-id
- An integer expression that evaluates to a valid tenant ID for a regular tenant of a multi-tenant database. This argument only has meaning for a multi-tenant-enabled sequence. For more information on using multi-tenant sequences, see Using multi-tenant-enabled sequences.
A dynamic sequence statement and functions have a similar general syntax, but allow you to specify the sequence and database dynamically at run time. Their syntax is as follows:
Syntax
|
Syntax
|
- sequence-name-expression
- A character expression which evaluates to the name of a sequence defined in the Data Dictionary. Note that a sequence can have the same name as a database field, but they are distinct entities.
- logical-dbname-expression
- A character expression which evaluates to the logical name of the database in which
the sequence is defined. The database must be connected. This argument is required and
cannot be Unknown value (
?). - expression
- An expression that evaluates to an integer value. The
DYNAMIC–CURRENT–VALUEstatement assigns the value of expression to the specified sequence. The value of expression must be within the range defined for the specified sequence. - tenant-id
- An integer expression that evaluates to a valid tenant ID for a regular tenant of a multi-tenant database. This argument only has meaning for a multi-tenant-enabled sequence. For more information on using multi-tenant sequences, see Using multi-tenant-enabled sequences.
In general, use the CURRENT–VALUE and NEXT–VALUE functions
for mission-critical applications that depend on access to reliable
and orderly sequence values. Use the CURRENT–VALUE statement
only for database maintenance and initialization, primarily during
the development cycle. For more information on these functions and
statements, see ABL Reference.