Subject | RE: [firebird-support] Re: problem with insert or update |
---|---|
Author | Sasha Matijasic |
Post date | 2008-08-13T16:18:28Z |
>It's not strange, really. This is what probably happened.
> Hello,
>
> I have deleted all my records (it was a very small table) and insert
> again them and now it seems that it is good. I can add records!
>
> Strange...
>
You have a row with id = 4.
Your current value of generator is 3.
insert into table(id) values(null);
trigger fires and checks if id is null or 0.
if ( (new.ID is null) or (new.ID = 0) )
then new.ID = gen_id(CODECOMPTA_GEN, 1);
id gets the value 4. Voila, you get a violation of primary key.
Instead of deleting all data from table, you could have done:
alter sequence CODECOMPTA_GEN restart with x;
where x is max(id) from CODECOMPTA table.
Sasha