Subject | Re: Inserting into child table with foreign key constraint |
---|---|
Author | jeff_j_dunlap |
Post date | 2009-02-22T04:09:33Z |
--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@...>
wrote:
first record went in with a manually-determined PK value of 36. But
your generator was sitting there on 35 - with the next value to be
generated as 36. So, when the trigger fired, you got a PK violation.
of internal magic. It doesn't happen. In applications, if you're
generating keys you must make them unreachable by humans.
there to get the generator syncronized. It was a really dumb or rather
lack of experience mistake on my part using a domain that defaults the
value to zero but that won't happen again! :)
wrote:
> The trigger's working fine! :-) The error you got here was a primarykey/uniqueness violation, not a referential integrity violation. The
first record went in with a manually-determined PK value of 36. But
your generator was sitting there on 35 - with the next value to be
generated as 36. So, when the trigger fired, you got a PK violation.
>cause the generator to synchronise itself with the table by some kind
> Perhaps you thought that poking that value in manually would somehow
of internal magic. It doesn't happen. In applications, if you're
generating keys you must make them unreachable by humans.
>You're totally right Helen, I did try poking that and higher values in
> ./heLen
there to get the generator syncronized. It was a really dumb or rather
lack of experience mistake on my part using a domain that defaults the
value to zero but that won't happen again! :)