Canceling Pending Cached Updates

From InterBase

Go Up to Using Cached Updates


Pending cached updates are updated records that are posted to the cache but not yet applied to the database. There are three ways to cancel pending cached updates:

  • To cancel all pending updates and disable further cached updates, set the CachedUpdates property to False.
  • To discard all pending updates without disabling further cached updates, call the CancelUpdates method.
  • To cancel updates made to the current record call RevertRecord.

The following sections discuss these options in more detail.

Cancelling Pending Updates and Disabling Further Cached Updates

To cancel further caching of updates and delete all pending cached updates without applying them, set the CachedUpdates property to False. When CachedUpdates is set to False, the CancelUpdates method is automatically invoked.

From the update cache, deleted records are undeleted, modified records revert to original values, and newly inserted record simply disappear.

Note:
This option is not available for client datasets.

Discarding Pending Cached Updates

CancelUpdates clears the cache of all pending updates, and restores the dataset to the state it was in when the table was opened, cached updates were last enabled, or updates were last successfully applied. For example, the following statement cancels updates for the CustomersTable:

CustomersTable.CancelUpdates;

From the update cache, deleted records are undeleted, modified records revert to original values, and newly inserted records simply disappear.

Note:
Calling CancelUpdates does not disable cached updating. It only cancels currently pending updates. To disable further cached updates, set the CachedUpdates property to False.

Canceling Updates to the Current Record

RevertRecord restores the current record in the dataset to the state it was in when the table was opened, cached updates were last enabled, or updates were last successfully applied. It is most frequently used in an OnUpdateError event handler to correct error situations. For example,

CustomersTable.RevertRecord;

Undoing cached changes to one record does not affect any other records. If only one record is in the cache of updates and the change is undone using RevertRecord, the UpdatesPending property for the dataset component is automatically changed from True to False.

If the record is not modified, this call has no effect. For more information about creating an OnUpdateError handler, see Creating an OnUpdateRecord Event Handler.

Advance To: