I have a simple master detail relation that I would like to manage using cached updates.
I am able to make it work... most of the time.
I did set the detail dataset option to LocalMasterDetail like I found in other posts.
When applying updates, it looks like the order of the datasets have an impact on the results.
When applying updates after inserting a new master the applyupdate should be like :
IBCConnection1.ApplyUpdates([MasterIBCQuery, DetailIBCQuery]);
and when applying updates after deleting the details AND the master it should be like:
IBCConnection1.ApplyUpdates([DetailIBCQuery, MasterIBCQuery]);
Applying update only on the master doesn't propagate to the details, saving only the master (unlike the ClientDataset).
Am I missing something ?
Should it apply the updates in the correct order depending on the type of edit ?
Thanks,
Pascal
Delphi XE
IBDAC 4.1.3
Firebird 2.5.1
Cached Updates and Master Detail
-
AndreyZ
Hello,
The only case when you need to apply updates of the master table before applying updates of the detail table is when the master table has IDENTITY fields (autoincrement). In this case, you should insert new records to the master table, apply updates of the master table, and then insert new records to the detail table. Otherwise, detail table will not get foreign key fields values (that are used to establish master/detail relationship). In all other cases you can apply updates of the master and detail tables in any order.
The only case when you need to apply updates of the master table before applying updates of the detail table is when the master table has IDENTITY fields (autoincrement). In this case, you should insert new records to the master table, apply updates of the master table, and then insert new records to the detail table. Otherwise, detail table will not get foreign key fields values (that are used to establish master/detail relationship). In all other cases you can apply updates of the master and detail tables in any order.