Master record lost on exception

I have two tables in a master/detail type of arrangement using cached
updates.
(I'm using Delphi 3 C/S and SQL Server 7)

MasterTable
    PersonID
    ...

DetailTable
    PersonID
    Effective Date
    ...

The tables are NOT linked using the DataSource property of the detail
table's TQuery component, instead they have a foreign key constraint defined
in the database.
After inserting a master and a detail record, I applyupdates to the master
table first then the detail table (all within the same transaction).
If the master table updates ok but some kind of data error causes the detail
table update to fail, then after rolling back the transaction the master
record disappears. Any further attempts to update result in a foreign key
constraint error because it is effectively trying to insert a detail record
that does not have any matching master record.
Any help on this matter would be greatly appreciated.

Mark.