Subject RE: [firebird-support] why reset all generators?
Author Svein Erling Tysvær
I think you can do something like

SELECT GEN_ID(gen_table1_id, (select max(id) from table1) - GEN_ID(gen_table1_id, 0))
FROM rdb$database

to set the generator to a specific value. But it is a few years since I tried to do something like this, and I don't know if recent versions of Firebird allows this kind of syntax (nor am I certain whether I remember correctly). If the generator value is 0, you do not need to subtract anything.

You risk primary key violations if done concurrently with other DML statements (e.g. if someone has created, but not yet committed insertion of a new, higher ID).

HTH,
Set

-----Original Message-----
From: firebird-support@yahoogroups.com [mailto:firebird-support@yahoogroups.com] On Behalf Of Orhan TURHAN
Sent: 2. april 2008 16:33
To: firebird-support@yahoogroups.com
Subject: [firebird-support] why reset all generators?

table1
id
-----
100

table2
id
-----
23


...
..

Generators
gen_table1_id = 0
gen_table2_id = 0

i want to set all generator values from table id's.

thanx.