DelphiFAQ Home Search:
General :: Databases :: InterBase
Help with InterBase, Borland's open source database.


This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

Fixing a broken generator (InterBase)

Recently I got unique key violations during insert attempts on a piece of code that used to work (what can go bad, will go bad). I found that the offending field - was actually created by a generator. For some reason the generator returned values that where already in the database.


- how can I display the current value of the generator?
- how can I adjust the value of the generator?


See the example (table name is SD_LOAD, generator name is GEN_SD_LOAD).


You cannot modify the value of the generator inside of a trigger or stored procedure. You only can call the gen_id() function to increment the value in a generator. The SET GENERATOR command will only work outside of a stored procedure or trigger.

SELECT DISTINCT(GEN_ID(gen_sd_load, 0)) FROM sd_load
 SET GENERATOR gen_sd_load TO 2021819
You don't like the formatting? Check out SourceCoder then!
Generated 20:00:44 on Mar 21, 2018