Subject Re: Key violation on Primary/Unique key constraint INTEG_55/30 on table(s)
Author Svein Erling Tysvær
I haven't followed this thread, so I apologize if my suggestion has
been mentioned before.

With creating the database, the generators may have been set to 0, and
since you disabled the triggers, they never advanced. Pumping the data
filled the ID field and whenever you now try to insert a new record,
your database will try to use a number that has already been assigned.

This is easy enough to check.

SELECT GEN_ID(PEOPLEIDGEN, 0) FROM RDB$DATABASE

SELECT MAX(ID) FROM PEOPLE

If the first query returns a lower number than the latter, then you've
probably found your problem.

HTH,
Set

--- In firebird-support@yahoogroups.com, "Gaurav Sood" wrote:
> Except one thing:
>
> I created the database using IBPump, and probably Disabled the
> Triggers when I pumped the data, perhaps that could be a problem ?
> how do I check or enable all the triggers ?
>
> > > > I found there is a separate trigger for PeopleID as follows;
> > > >
> > > >
> > > > CREATE TRIGGER CREATEPEOPLEID FOR PEOPLE
> > > > ACTIVE BEFORE INSERT POSITION 0
> > > > AS BEGIN
> > > > NEW.ID = GEN_ID(PEOPLEIDGEN, 1);
> > > > END ^
> > >
> > > This will always assign a new generated value to ID. This is a
> > > valid way of doing what was done in Delphi, however be aware
> > > that in FB 1.5 you have no way of seeing the value of NEW.ID if
> > > you do it this way.
> > >
> > > A better approach is
> > >
> > > CREATE TRIGGER CREATEPEOPLEID FOR PEOPLE
> > > ACTIVE BEFORE INSERT POSITION 0
> > > AS
> > > BEGIN
> > > IF (NEW.ID IS NULL) THEN
> > > BEGIN
> > > NEW.ID = GEN_ID(PEOPLEIDGEN, 1);
> > > END
> > > END
> > > ^
> > >
> > > This will only generate an ID if you do not explicitly define
> > > one.