Subject RE: [firebird-support] Restore errors - missing FK
Author Bob Murdoch
-----Original Message-----
> That is weird.
>
> The SQL which Karol provided should have found the problem/missing values from the Account table.
>
> I can only think of 2 options of the top of my head:
>
> 1- Try a slightly different SQL query, though it should be the same as Karol's (Select * from zip_code_account z where not
> exists(select * from account a where a.account_id + 0 = z.account_id + 0
> 2- Try to download v2.5.1 engine and perform backup/restore using that GBAK version.

Thanks Sean. I did try the same updated query that you provided with no luck.

However, I did discover the problem while trying to alter the data in this table. As it turns out, we had added a NOT NULL column to the table, but did not go back and put a value in that column for the existing records.

When I saw that an error had occurred in the restore, I immediately jumped to the last lines in the restore log (since that is usually where you see the errors), and saw the FK failures. What I should have done is look further up in the file, where I would have found the actual cause of the problem:

gbak:restoring data for table ACCOUNT
gbak:validation error on column in table ACCOUNT
gbak: ERROR:validation error for column INS_USER_ID, value "*** null ***"

The reason the FKs were not being built is because there were no records in the ACCOUNT table due to this not null validation error.

Thanks to everyone that took the time to look at this rookie mistake (although I've been using FB since IB 5.5!).

Bob M..