8.8 Functions for Sequences (Generators)
8.8.1 GEN_ID()
Available inDSQL, ESQL, PSQL
Result typeBIGINT
Syntax
GEN_ID (generator-name, step)
Table 8.8.1.1 GEN_ID
Function Parameters
Parameter | Description |
---|---|
generator-name | Name of a generator (sequence) that exists. If it has been defined in double quotes with a case-sensitive identifier, it must be used in the same form unless the name is all upper-case. |
step | An integer expression |
Increments a generator or sequence and returns its new value. If step equals 0, the function will leave the value of the generator unchanged and return its current value.
- From Firebird 2.0 onward, the SQL-compliant NEXT VALUE FOR syntax is preferred, except when an increment other than 1 is needed.
Warning
If the value of the step parameter is less than zero, it will decrease the value of the generator. Attention! You should be extremely cautious with such manipulations in the database, as they could compromise data integrity.
8.8.1.1 GEN_ID
Example
new.rec_id = gen_id(gen_recnum, 1);