Using Dataset Cached Updates

From InterBase

Go Up to Understanding Datasets

Cached updates enable you to retrieve data from a database, cache and edit it locally, and then apply the cached updates to the database as a unit. When cached updates are enabled, updates to a dataset (such as posting changes or deleting records) are stored in an internal cache instead of being written directly to the dataset’s underlying table. When changes are complete, your application calls a method that writes the cached changes to the database and clears the cache.

Implementation of cached updating occurs in TIBCustomDataSet. The following table lists the properties, events, and methods for cached updating:

Properties, events, and methods for cached updates
Property, event, or method Purpose

CachedUpdates property

Determines whether or not cached updates are in effect for the dataset. If True, cached updating is enabled. If False, cached updating is disabled.

UpdateObject property

Indicates the name of the TUpdateSQL component used to update datasets based on queries.

UpdatesPending property

Indicates whether or not the local cache contains updated records that need to be applied to the database. True indicates there are records to update. False indicates the cache is empty.

UpdateRecordTypes property

Indicates the kind of updated records to make visible to the application during the application of cached updates.

UpdateStatus method

Indicates if a record is unchanged, modified, inserted, or deleted.

OnUpdateError event

A developer-created procedure that handles update errors on a record-by-record basis.

OnUpdateRecord event

A developer-created procedure that processes updates on a record-by-record basis.

ApplyUpdates method

Applies records in the local cache to the database.

CancelUpdates method

Removes all pending updates from the local cache without applying them to the database.

FetchAll method

Copies all database records to the local cache for editing and updating.

RevertRecord method

Undoes updates to the current record if updates are not yet applied on the server side.

Using cached updates and coordinating them with other applications that access data in a multi-user environment is an advanced topic that is fully covered in Working with Cached Updates.

Advance To: