Subject Re: [firebird-support] Foreign key constraint violation
Author Kjell Rilbe
hfsnell wrote:

> --- In firebird-support@yahoogroups.com
> <mailto:firebird-support%40yahoogroups.com>, Kjell Rilbe <kjell.rilbe@...>
> wrote:
> > OK, so do these import operations fail or otherwise get interrupted
> > sometimes?
> >
> > And if your check fails - the db is not found to be "in god status",
> > what do you do?
>
> Usually, when my customer called me and complained about a bad action
> in my software. I checked my db and found this error. I viewed the log
> file and found out a violated foreign key error when importing data
> from xls file.
> The error message implies that the constraint operated well. The thing
> I don't know how the data could insert into the child table and it
> still existed after the error had occured.

If I understand you correctly, this is what happens:

1. Disable FK constraint.
2. Import from xls.
3. Enable FK constraint -> FK violation.

If this is the case, then of course the child remains in the table. It
wasn't the import that failed. It was the reenableing of the FK
constraint that failed.

When that happens, your app needs to check what records violate the
constraint and take appropriate action. Then make sure the FK is
properly reenabled.

If this is not what happens, then you haven't given me... us... all the
info about what your app is doing. In that case, please provide this info.

Kjell
--
--------------------------------------
Kjell Rilbe
DataDIA AB
E-post: kjell@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64