Subject | Re: problem with insert or update |
---|---|
Author | calou_3324 |
Post date | 2008-08-13T20:07:22Z |
Hello,
Regards
> It's not strange, really. This is what probably happened.Thank you for the explanations. I understant what happen
>
> 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
>
Regards