Subject Re: [Firebird-Java] Get generator field value
Author Roman Rokytskyy
> I want to append a record to a table where the key field has a generator
> defined in the Firebird database.
> I can not retrieve the generated value, and I cannot append records
> without assigning the key field a value.
> Is this done in the dataset definitions, or is there a method to get the
> generated value?

To get the next value of the generator you can use

SELECT gen_id(generator_name, 1) FROM rdb$database

The second parameter is the "size" of the ID block (1 - single ID, 10 - ten
sequential IDs).

If you do not need the generated value later in your application, you can
use following:

id INTEGER NOT NULL DEFAUL gen_id(some_generator, 1) PRIMARY KEY,
col1 ...,
col2 ...,

and then simply

INSERT INTO bla(col1, col2, ...) VALUES (....)

without specifying the ID column.