|
<< Click to Display Table of Contents >> DbiApplyDelayedUpdates |
![]() ![]()
|
C syntax
DBIResult DBIFN EXPORT DbiApplyDelayedUpdates (hCursor,eUpdCmd);
typedef enum // Op types for cached updates cursor
{
dbiDelayedUpdCommit = 0 // Commit the updates
dbiDelayedUpdCancel = 1 // Rollback the updates
dbiDelayedUpdCancelCurrent = 2 // Cancel current record change
dbiDelayedUPDPREPARE = 3 // Phase 1 of two-phase commit
} DBIDelayedUpdCmd;
Delphi syntax
function DbiApplyDelayedUpdates (hCursor: hDBICur; eUpdCmd: DBIDelayedUpdCmd): DBIResult stdcall;
Description
When the cached updates mode is active, DbiApplyDelayedUpdates writes any changes made to cached data to the underlying database, or rolls back all modifications made to the cached data. DbiApplyDelayedUpdates sends to the database a batch of all inserts, deletes, and modifications made since the last DbiApplyDelayedUpdates function call.
Parameters |
||
hCursor |
Type: hDBICur |
(Input) |
Specifies the cached updates cursor handle. |
||
eUpdCmd |
Type: DBIDelayedUpdCmd |
(Input) |
Specifies the operation to be performed on the cached updates cursor. |
||
Usage
After making the changes to table data cached by the cached updates mode, call DbiApplyDelayedUpdates either to commit (write to the actual table) or rollback the changes. The rollback operation quickly discards the update information from the cache.
You may continue modifying data in the cached updates mode after calling DbiApplyDelayedUpdates. When you are ready to write the modified data permanently, call DbiApplyDelayedUpdates to commit changes to the actual database. When finished, DbiEndDelayedUpdates closes the cached updates mode.
Use of the cached updates mode is a two-phase process involving the use of the operation types for the cached updates cursor:
Phase 1: The operation DbiDelayedUpdPrepare causes all changes in the cache to be applied to the underlying data. Unless being used in a single-user environment, this operation 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 operation dbiDelayedUpdateCommit performs the second phase. After successfully calling DbiDelayedUpdPrepare directly, follow it with the dbiDelayedUpdateCommit operation. 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).
There are two ways to cancel changes made while cached updates are enabled:
The operation dbiDelayedUpdCancel clears the cache and restores the dataset to the state it was in when:
- the table was opened,
- cached updates were enabled, or
- updates were last successfully applied.
The operation dbiDelayedUpdCancelCurrent restores the current record in the dataset to an unmodified state. If the record was not modified this call has no effect. This operation is similar to the dbiDelayedUpdCancel operation but operates only on the current record.
Standard: Every non-blob field is used in determining the record modifications
Prerequisites
A call to DbiBeginDelayedUpdates must have been made.
DbiResult |
Meaning |
DBIERR_NONE |
The update information in the temporary cache was successfully written to the database. |
See also
DbiBeginDelayedUpdates, DbiEndDelayedUpdates, Cached updates