Product Documentation

VCL/CLX Developers Guide

Previous Topic

Next Topic

Terminating a transaction

When all update operations have been completed, terminate a transaction by calling CommitTransaction() method to commit all changes.

Call AbortTransaction() method to terminate the transaction and abort all changes done since the start of the transaction.

Previous Topic

Next Topic

Save Points

There are times when you want to abort only a portion of a transaction. You may be processing several optional paths of a program, going down one branch, then backing out and trying another branch. It may be possible that you don't want any of the updates to occur until you are completely finished, but you want the flexibility to back out part of the updates. Another possibility would be if you have run into some form of update error, such as an add record failing due to a duplicate key. You would want to back up to a prior point, correct the problem, and continue. The c-treeDB API allows you to implement this by using savepoints.

A savepoint is a temporary spot in the transaction that you may want to roll back to without having to abort the entire transaction. During a transaction, when you want to put a place mark in the process, issue a ctdbSetSavePoint() call. This does not commit any of the updates. The function returns a savepoint number, which you should keep track of. You can make as many ctdbSetSavePoint() calls as you wish during a transaction, and each time you will be given a savepoint number, which is unique to the current transaction.

When you decide that you want to roll back to a savepoint previously saved by a call to ctdbSetSavePoint(), issue a ctdbRestoreSavePoint() call, passing in the desired savepoint number. This returns your data to the state it was at the point you issued the specified ctdbSetSavePoint() call, without aborting the entire transaction.

TOCIndex