Master/detail Cascade Deletes - what am I missing?

Hi,

I’ve set up two TDAMemDataTables with the Master Detail wizard (using mmWhere) but I cannot get my app to delete the detail records from the database when the master record is deleted. When I call tbl_Master.Delete the tbl_Detail records also are deleted in the app, but the changes are not applied on the server when ApplyUpdates is called – this leaves orphaned records. I don’t have, nor do I want to use Foreign Keys.

Here’s my setup

  • tbl_Master.DetailOptions.dtDisableLogOfCascadeDeletes = False (i.e. I have no foreign keys so need the change log)
  • tbl_Detail.MasterOptions.moCascadeApplyUpdates = True (I believe this is default)
  • tbl_Detail.MasterOptions.moCascadeDeletes = True (I believe this is default)
  • tbl_Detail.MasterOptions.moCascadeOpenClose = True (I believe this is default)
  • I have specifed master/detail relationships in the Schema to link Master with Detail via the correct ID field.
  • I have also added Update Rules to the Schema to specify the order of inserts/deletes (although without foreign keys in the database, I think this is unnecessary)
  • I have TDABusinessProcessor’s for each data-table on the schema – these do’n’t interfere with deletes, but just implement an OnProcessChange event handler to capture and log all DB changes to XML.

What else am I missing please?

Thanks

Delphi XE6
RO/DA 8.3.91.1167

you need to set tbl_detail.DetailOptions.dtDisableLogOfCascadeDeletes = False

Great, thanks, I knew I was missing something :slight_smile: