Firebird Documentation IndexFirebird 2.0 Language Ref. UpdateInternal functions → GEN_ID()
Firebird Home Firebird Home Prev: EXTRACT()Firebird Documentation IndexUp: Internal functionsNext: IIF()

GEN_ID()

Available in: DSQL, ESQL, PSQL

Description: Increments a generator or sequence and returns its new value. From Firebird 2.0 onward, the SQL-compliant NEXT VALUE FOR syntax is preferred, except when an increment other than 1 is needed.

Result type: BIGINT

Syntax: 

GEN_ID (generator-name, <step>)

<step>  ::=  An integer expression.

Example: 

new.rec_id = gen_id(gen_recnum, 1);

Warning

Unless you know very well what you are doing, using GEN_ID() with step values lower than 1 may compromise your data's integrity.

See also: NEXT VALUE FOR, CREATE GENERATOR

Prev: EXTRACT()Firebird Documentation IndexUp: Internal functionsNext: IIF()
Firebird Documentation IndexFirebird 2.0 Language Ref. UpdateInternal functions → GEN_ID()