Using transactions

<< Click to Display Table of Contents >>

Navigation:  Application development > Transactions >

Using transactions

Previous pageReturn to chapter overviewNext page

BDE provides two API functions: DbiBeginTran, to begin transactions and DbiEndTran, to end transactions:

DBIResult DBIFN DbiBeginTran (                // Begin a transaction
   hDBIDb         hDb,                          // Db handle
   eXILType       eXIL,                         // Transaction isolation level
   phDBIXact      phXact                       // Returned. Xact handle
); 

         // Commit or rollback a basic transaction. If hXact is
// given, hDb is ignored. If hXact == 0, hDb must be given.

 

DBIResult DBIFN DbiEndTran (                   // End a transaction
   hDBIDb         hDb,                        // Database handle
   hDBIXact       hXact,                      // Xact handle
   eXEnd          eEnd                          // Xact end type
);

         // The transaction model being discussed here supports only
// xilDIRTYREAD isolation level.

typedef enum                                                // Transaction isolation levels
{
      xilDIRTYREAD,                                // Uncommitted changes read
      xilREADCOMMITTED,                // Committed changes, no phantoms
      xilREPEATABLEREAD                // Full read repeatability
} eXILType;

typedef enum                                        // Transaction end control
{
      xendCOMMIT,                                    // Commit transaction
      xendCOMMITKEEP,                                // Commit transaction, keep cursors
      xendABORT                                      // Rollback transaction
} eXEnd;

 

The following results occur when there are active transactions:

1.If there are active transactions in a session, DbiCloseSession closes that session and its active transactions are rolled back. Similarly, DbiExit rolls back the active transactions present in the system.

2.In the case of standard databases (local transactions), DbiModifyRecord, DbiInsertRecord, and DbiDeleteRecord are intercepted to perform the transaction logging. A separate log is associated with each transaction. The log is maintained as long as the transaction is active. It is destroyed once the transaction commits or rolls back.

 

hmtoggle_plus1Transaction topics