Master-Detail ClientDataSet update sequence

Master-Detail ClientDataSet update sequence

Post by Max » Tue, 25 Apr 2006 16:33:41


I have 2 clientdataset, one for the master and the other for the
detail.

For every record that is changed (inserted/deleted/update), both in
master and client, i need to update a field in another table by
calling a method. This is my update sequence in pseudo-code

procedure TDocumenti.MasterBeforeUpdateRecord(Sender: TObject;
SourceDS: TDataSet; DeltaDS: TCustomClientDataSet;
UpdateKind: TUpdateKind; var Applied: Boolean);
begin
fValue := .. one field value ..
end;

procedure TDocumenti.DetailBeforeUpdateRecord(Sender: TObject;
SourceDS: TDataSet; DeltaDS: TCustomClientDataSet;
UpdateKind: TUpdateKind; var Applied: Boolean);
begin
Modify_Item_Qty (fvalue, detail field value)
end;

The problem is that if the user modify only the master the
Modify_Item_Qty is not called, if the user modify only the detail the
fValue is no set.
 
 
 

Master-Detail ClientDataSet update sequence

Post by Ralf Janse » Wed, 26 Apr 2006 03:22:04

Posting a detail should be no problem. You can just reference the master record without fvalue
(i assume fvalue holds something from the master record).

If you are posting the Master just iterate through all attached details in the Masters
AfterUpdateRecord event and call Modify_Item_Qty from there.

Ralf