RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TDatabase.ApplyUpdates Method

Posts pending cached updates for specified datasets to the database server.

Pascal
procedure ApplyUpdates(const DataSets: array of TDBDataSet);
C++
__fastcall ApplyUpdates(const array of TDBDataSet DataSets);

Call ApplyUpdates to post pending cached updates for a specific set of open datasets to the database server. ApplyUpdates is only meaningful if the CachedUpdates property of a specified dataset is true. 

DataSets is a list of dataset names specifying the datasets for which to post pending updates. DataSets need not list every currently open dataset. For each listed dataset ApplyUpdates calls the dataset's ApplyUpdates and CommitUpdates methods to post that dataset's pending cached updates. 

Applying updates is a two-phase process that takes place within the context of the database component's transaction control. When an application calls ApplyUpdates, the following events take place: 

1A database transaction starts. 

2Cached updates are written to the database (Phase 1). 

If the database write is successful: 

1 Database changes are committed, ending the transaction. 

2 CachedUpdates are committed, clearing the internal cache buffer (Phase 2). 

If the database write fails database changes are rolled back, ending the transaction. 

The two-phased approach allows for effective error recovery, especially when updating multiple and interrelated datasets (for example, the datasets associated with a master/detail form). 

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!