Firebird Documentation IndexFirebird 2.1 Language Ref. UpdateInternal functions → GEN_ID()
Firebird Home Firebird Home Prev: FLOOR()Firebird Documentation IndexUp: Internal functionsNext: GEN_UUID()

GEN_ID()

Available in: DSQL, ESQL, PSQL

Added in: IB

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: FLOOR()Firebird Documentation IndexUp: Internal functionsNext: GEN_UUID()
Firebird Documentation IndexFirebird 2.1 Language Ref. UpdateInternal functions → GEN_ID()