FairCom Corporation
 
FairCom Start PageFairCom ProductsDownloadsDeveloper SupportSales InformationFairCom CustomersFairCom Company InformationContact FairCom

Homebulletgrey.gifeNewsletterbulletgrey.gifVolume 21bulletgrey.gifSession-Based Transaction Processing


c-treeDB Transaction Processing is Session-Based!

Help! I received error 71 (TNON_ERR - no active transaction)!

A common error observed by developers using the c-treeDB C or C++ programming API results from the fact that transactions are held session-wide. Usually this results from an attempt to create a nested transaction. While c-tree Plus does not support nested transactions, it does provide powerful savepoint and rollback features.

The general situation occurs as demonstrated in the following c-treeDB C++ pseudo code:

mySession->Begin();
	// do some Session operations
 
	myTable->Begin();
		//do more Table operations
	myTable->Abort();
 
mySession->Commit();

The result from this example is a TNON_ERR error (71). Why?

Transactions are held session-wide with c-treeDB. Thus, when the Abort is encountered in the table operations, the transaction started in the session is terminated. When the session Commit occurs, you receive error 71, as there is no active transaction at that time.

While all of the c-treeDB transaction processing functions, ctdbBegin , ctdbAbort , ctdbCommit and ctdbIsTransActive , receive a session handle as a parameter, ANY handle will suffice. c-treeDB always knows how to determine the session handle associated with any handle.

The following example demonstrates one solution using savepoints to avoid this situation:

mySession->Begin();
	// do some Session operations
 
	myTableSavePoint = myTable->SetSavePoint();
		// do some Table operations
		
		// `Abort' the table operations
		myTable->RestoreSavePoint(myTableSavePoint)
 
	// other operations
mySession->Commit();

"If I had known that it would be this easy, I would have switched to client/server a long time ago."

Andrew Hallonquist
A H Computer Systems Ltd.

FairCom Start PageSite MapContact FairComThe FairCom Privacy Policy Your Location: USA | Europe | Brazil | Japan
Copyright 2012 FairCom Corporation. All rights reserved.