Product Documentation

c-treeDB API for C++ - Developers Guide

Previous Topic

Next Topic

Starting a transaction

Using our example from above, you don’t want to have the transaction group involve more than one invoice. You also don’t want it to involve less than a whole invoice.

Record locks are held on updated records for the duration of the transaction, so you don’t want to make the transaction group too large or it will consume the system resources and cause delays. On the other hand, you may not want to make the transaction group too small or the effect of grouping actions is lost.

The Begin method of classes CTSession(), CTDatabase(), CTTable() and CTRecord() starts a new transaction. Choose logical groups of file updates to be delimited as transactions.

// start a new transaction

try

{

ARecord.Begin()

}

catch (CTException &err)

{

printf("Begin transaction failed with error %d\n", err.GetErrorCode());

}

TOCIndex