Subject Re: [firebird-support] Auto-increment generating old ID's for insertion
Author Lester Caine
On 02/04/18 13:11, 'Joje' joje@... [firebird-support]
wrote:
> I have issue where auto-increment of ID column is generating older ID’s
> that is already used in table.
>
> Currently, my transaction table has around 16 million rows and *ID of
> last inserted row is 16,594,027*.  While the *generator ID its
> 16,593,965*.  As you can see the generator is generating ID’s that is
> already present in table which causes *violation of PRIMARY or UNIQUE
> KEY constraint "INTEG_105"*error on that table.
>
> I managed to fix this issue, recently I am facing it frequently on this
> transaction table, majority of the tables had number of records are more
> than 2 million or there is connectivity issues with DB.
>
> Now, I am wondering is this related to Firebird DB or is there any other
> issue.

Assuming that the ID is generated via the normal Firebird method, then
there is a generator linked with the auto-increment. If the generator
has been reset for some reason this would explain the current problem.
Simply setting the generator above the current highest value will fix
this. However we do need to check out just how the new value is
generated as well.

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk