Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How can I save the changes of a single record from a TClientDataSet which has more than one change.

2 views
Skip to first unread message

Ramin

unread,
May 16, 2008, 4:06:06 AM5/16/08
to
Hi. I am using Delphi 6 with dbExpress. I have a question about
controlling what records to save - i.e. controlling what goes into the
delta and thus will be reconciled.

TClientDataSet.ApplyUpdates always sends the complete Delta to the
Provider. What I need is something like ApplyCurrentRecord. I
implemented a briecase model and users can change several records with
detail data offline and then commit the changes once connected to the
server. I want to send the records one-by-one, especially since each
record has nested datasets and each master record together with the
details needs to be saved within one transaction - either all changes
for that master/detail record get committed or all rolled back. If not
sending the records one-by-one, there is no control over this fact.
With ApplyUpdates(-1) details might be deleted before an UpdateError
on the Master occurs or a master record may be inserted and an error
occurs inserting the detail record, and with ApplyUpdates(0) all
changes will be rolled back if there is any UpdateError, and not just
those belonging to the master/detail-record which caused the error.

The solution I chose is to make a copy of each master/detail (nested)
record to other master/detail-ClientDataSets, saving these changes and
logging the result. Quite cumbersome. The problem is, that there is no
way of reconciling the result back to the original ClientDataSets,
since reconciling the Result of TProvider.ApplyUpdates for the one
record sets all other changes to "reconciled" as well, because the
Result contains only the erros and not the successes. Thus I need to
do alot of administration of the Data myself.

The other possibility would be to send the ID of the current record in
the OwnerData of BeforeApplyUpdates. The server then skips all records
with a key value different to the ID and saves only the changes for
the records (master and details) with the matching master-ID. Problem
here is that the traffic is pretty high, since the Delta sent to the
provider always contains all changes, even though only one change will
be saved. also, alot of reconcile-errors are sent back to the client,
which all need to be ignored instead of "real" errors. that doesn't
seem like a good solution.

Any suggestions, or maybe even simple solutions I am simply missing.
Help is greatly appreciated.
Thanx, Ramin

0 new messages