Chapter 5. Using Transactions

Table of Contents
DatabaseIf Support For Transactions
Suggested Use Of Transactions

DAME has simple support for transactions through the DatabaseIf interface. However, the transaction semantics differs from one database system to another database system. For example, In Oracle™ a database connection can start a transaction and still commit chosen SQL statements, where as Postgresql does not support such flexibility. DAMEs support for transactions is rudimentary in nature, but still useful and enough for a lot of applications.

DatabaseIf Support For Transactions

Every database connection supports a autocommit. By default, the autocommit for a database connection is set to true. Every SQL statement executed using this database connection is committed to the database and immediately visible to all other connections.

You need to turn the autocommit off using SetAutoCommit before you can make use of transaction capabilities. You need to use StartTransaction to start a transaction. It is expected that a transaction is always committed or rollbacked using functions Commit and Rollback.

Transaction Semantics For Oracle

DAME library for Oracle™ uses the default transaction created by Oracle™ OCI call to open a database connection. If the autocommit flag is turned on after a transaction is started all the database updates from then on are Committed to the database till the flag is turned off. One still need to commit or rollback the transaction to commit/rollback changes that were made while the autocommit flag is turned off.

Transaction Semantics For Postgresql

DAME library for Postgresql uses the "BEGIN WORK" SQL statement to start a transaction. The autocommit flag does not have any bearing on the database updates that take place during the transactions.