Callback functions

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

Callback functions

Return to chapter overview

A callback mechanism is provided when a failure to write a modified record to the database occurs. Because updates are not sent to the underlying table until the commit time, no errors (such as integrity constraint violations) are detected before the commit/prepare operation. If an error occurs at commit time, users are prompted with an error message describing the error. Applications should register a callback function for cached updates by using the DbiRegisterCallBack function (ecbType for this callback is cbDELAYEDUPD) to be notified of the errors during the commit.

The callback descriptor for cached updates is:

// type of delayed update object (cached updates callback)

typedef enum
{
      delayupdNONE        = 0,
      delayupdMODIFY      = 1,
      delayupdINSERT      = 2,
      delayupdDELETE      = 3
} DelayUpdErrOpType;

// cached updates callback descriptor.

typedef struct
{
      DBIResult           iErrCode;
      DelayUpdErrOpType   eDelayUpdErrOpType;
      // Record size (physical record)
      UINT16              iRecBufSize;
      pBYTE               pNewRecBuf;
      pBYTE               pOldRecBuf;
} DELAYUPDCbDesc;

 

In the callback descriptor, the eDelayUpdErrOpType indicates the operation type (such as insert, delete, or modify) and iErrCode indicates what sort of error has occurred during the eDelayUpdErrOpType operation.

Clients should allocate enough memory for pNewRecBuf and pOldRecBuf. Each record buffer should be at least as large as the cached update cursor’s physical record buffer size. The new (after the update) and old (before the update) record buffers are returned to the clients through pNewRecBuf and pOldRecBuf record buffers.

Clients can respond to this callback function with the following return codes:

Return code

Resulting action

cbrABORT

The entire commit operation is aborted. cbrABORT is the default return code if no callback function is registered.

cbrSKIP

The failed update operation is skipped and the commit process continues with the remaining updates.

cbrCONTINUE

The failed update operation is skipped and the commit process continues with the remaining updates.

cbrRETRY

The failed update operation is tried again.

cbrPARTIALASSIST

The user-applied changes are kept in the cache. In this case, the user applies the changes to the original table.

 

hmtoggle_plus1Cached updates topics
hmtoggle_plus1Accessing and updating tables