I have Two tables you can simply call it Master Detail kinda attangement.
In my application the user creates a Master record and a corresponding detail records and finally save it.
for this purpose i used cachedupdates = true property.
It works fine if updates were for insertion,, wihle it fails if any Master record deleted.
if runtime user delete any master record i do
Code: Select all
sqlDetail.Filtered := false;
        sqlDetail.Filter := 'ID_MASTER = '+IntTostr(IdMaster);
        sqlDetail.Filtered := true;
        sqlDetail.First;
        while not sqlDetail.Eof do
          sqlDetail.Delete;
        sqlDetail.Filtered := false;
        sqlDetail.CheckBrowseMode;
        // Finally delete record in Master Table
        sqlMaster.First;
        SearchRecord([sqlMasterID_Master], [IdMaster]);     // My function to search Idmaster in query
         sqlMaster.Delete;Then on Save button i perform following.
Code: Select all
try
        dbc.StartTransaction;
        sqlMaster.ApplyUpdates;
        sqlDetail.ApplyUpdates; // Here i have FK error
      except
        if dbc.InTransaction then
          dbct.Rollback;
      end;By the way on:
ms-help://embarcadero.rs_xe2/Devart.SDAC/SDAC/Devart.Dac.TMemDataSet.CachedUpdates.htm
I read
Which options I need to set true?Note: When establishing master/detail relationship the CachedUpdates property of detail dataset works properly only when TCustomDADataSet.Options is set to True.