Using the cached updates mode

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

Using the cached updates mode

Return to chapter overview

Use of the cached updates mode is a two-phase process.

Phase 1
The command dbiDelayedUpdPrepare causes all changes in the cache to be applied to the underlying data. Unless being used in a single-user environment, this command should always be used within the context of a transaction to allow for error-recovery in the event of an error during the update. Any errors encountered during this phase should be handled through callback functions.

Phase 2
The command dbiDelayedUpdateCommit performs the second phase. After successfully calling dbiDelayedUpdPrepare directly, follow it with the dbiDelayedUpdateCommit command. The internal cache is updated to reflect the fact that the updates were successfully applied to the underlying database (that is, the successfully applied records are removed from the cache).

Procedure

To start the cached updates mode:

1.        Create the cached updates layer with a call to DbiBeginDelayedUpdates.

 DBIResult DBIFN EXPORT DbiBeginDelayedUpdates(phDBICur phDbiCur);

 

Note:        The record buffer size will be different in cached updates mode. You should reallocate record buffers once the cached updates layer is installed.
2.        Apply (commit) changes made to the cached updates cache with a call to DbiApplyDelayedUpdates.

         DBIResult DBIFN EXPORT DbiApplyDelayedUpdates (hDBICur

         hDbiCur, DBIDelayedUpdCmd eUpdCmd);

                         typedef enum

                         {

                           dbiDelayedUpdCommit = 0,

                           dbiDelayedUpdCancel = 1

                           dbiDelayedUpdCancelCurrent = 2

                           dbiDelayedUpdPrepare = 3

                         } DBIDelayedUpdCmd;

Note:        When used on inserted, deleted, or modified records, the command dbiDelayedUpdCancelCurrent resets the current record to its original state.
3.        Once the changes have been applied to the database, users can resume making changes to the database. They don’t have to end the cached updates mode. After completing the next batch of modifications, DbiApplyDelayedUpdates can be called to apply those changes to the database or perform a rollback.
4.        End the cached updates mode with a call to DbiEndDelayedUpdates.
       DBIResult DBIFN EXPORT DbiEndDelayedUpdates(phDBICur phDbiCur);

 

hmtoggle_plus1Cached updates topics
hmtoggle_plus1Accessing and updating tables