Subject Re: [firebird-support] Broken foreign keys
Author Alexandre Benson Smith
Rodrigo Goncalves wrote:

>Hi all,
>
>
>in some databases of our clients (3 in about a 100 clients) there has
>been a problem of records having values in some fields which do not
>match any value in their respective foreign fields. Using gfix on the
>database does not raise any error but with a backup/restore the error
>becomes clear since it can't recreate the indexes.
>
>
>Any idea why this happens?
>
>
>Tks
>Rodrigo
>
>
Rodrigo,

Probably you have broken/corrupted indices, that left orphan recods.

What you could now do is;
1.) Drop you FK;
2.) Search for the orphan records and delete then or update then to a
dummy parent record;
3.) Recreate your FK
4.) Make a back-up and restore it to somewhere else, so you don't risk
to lost your "working" database

But the most important task is try to know why the indexes get corrupted...

What version of FB, what OS ?


see you !

--

Alexandre Benson Smith
Development
THOR Software e Comercial Ltda.
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br