Subject Re: Key violation on Primary/Unique key constraint INTEG_55/30 on table(s)
Author Svein Erling Tysvær
--- In firebird-support@yahoogroups.com, "Gaurav Sood" wrote:
> Good insight Svein!
>
> That's one problem that I didn't know about and is infact the
> probable cause (most likely) as the first query produced a result of
> 103, where as the Max value for ID is 140.
>
> What do I do to set the Generator to the correct values here ?
> SET GENERATOR PEOPLEIDGEN TO 140 ?

Yes.

> How do I automate it for the rest of the tables which have
> generators controlling the insertion of values ?
>
> Thanks!

Automate? Well, I guess it should be possible, though it does require
some research. You have to query system table(s) to find the
generators and look for dependencies to find which generator is
affiliated with which table. Though if you generally use
<tablename>+'IDGEN' as the name of your generators it may be a bit
simpler. http://www.fbtalk.net/viewforum.php?id=13 does contain some
interesting queries that may help you get started.

Myself, I'm pretty lazy and guess I would just have added another
table to my database, a table which simply contains generator, table
and column name. Then it should be very easy to write a small program
that does this checking for you based on the values in the table.

HTH,
Set