Product Documentation

c-treeDB API for C++

Previous Topic

Next Topic

C++ c-treeDB Tutorial 4: Transaction Processing

drivers\drivers\cpp.nav\tutorials\ctpp_tutorial4.cpp

Now we will discuss transaction processing as it relates to the FairCom DB C++ Database Framework.

Transaction processing provides a safe method by which multiple database operations spread across separate tables/files are guaranteed to be atomic. By atomic, we mean that, within a transaction, either all of the operations succeed or none of the operations succeed. This "either all or none" atomicity ensures that the integrity of the data in related tables/files is secure.

Like all other examples in the c-tree tutorial series, this tutorial simplifies the creation and use of a database into four simple steps: Initialize(), Define(), Manage(), and You’re Done()!

Tutorial #4: Transaction Processing

Here we demonstrate transaction control.

  • Initialize() - Connects to the FairCom Database Engine.
  • Define() - Defines and creates our four tables/files.
  • Manage() - Adds rows/records to multiple tables/files under transaction control.
  • Done() - Disconnects from FairCom Database Engine.

Note our simple Main() function:

//

// main()

//

// The main() function implements the concept of "init, define, manage

// and you're done..."

//

int main (COUNT argc, pTEXT argv[])

{

#ifdef TRANPROC

Initialize();

Define();

Manage();

Done();

#else

printf("\nThis tutorial demonstrates basic Transaction Processing. Transaction Processing is not");

printf("\nactivated in your chosen c-tree's model. In order to run this program select a ");

printf("\nc-tree model that supports Transaction processing, like the Client-Side c-tree model.");

#endif

printf("\nPress <ENTER> key to exit . . .\n");

#ifndef ctPortWINCE

getchar();

#endif

return(0);

}

We suggest opening the source code with your own editor.

Continue now to review these four steps.

TOCIndex