Transaction Processing with RWDBConnection
Database vendors offer many different transaction models. The transaction model for the DB Interface Module provides a uniform, ANSI-compliant interface for all supported vendors. We summarize this model as follows:
*By default, all applications written with the DB Interface Module create RWDBConnections in autocommit mode; that is, the database server is responsible for managing all transactions implicitly. This is also known as ANSI-compliant mode.
*The DB Interface Module allows you to manage transactions explicitly through the following methods:
 
RWDBConnection::beginTransaction()
RWDBConnection::rollbackTransaction()
RWDBConnection::rollbackTransaction(const RWCString& savepoint)
RWDBConnection::commitTransaction()
RWDBConnection::setSavepoint(const RWCString& savepoint)
 
*You can start a transaction, which effectively turns autocommit to off, by explicitly calling:
 
RWDBConnection::beginTransaction()
*Similarly, you can terminate transactions by invoking the following methods:
 
RWDBConnection::rollbackTransaction() RWDBConnection::commitTransaction()
When either of these methods is invoked, the given RWDBConnection switches back to autocommit mode automatically when the outermost transaction is committed or rolled back.
NOTE: We use the term outermost transaction for consistency, as some database vendors support nested transactions, while others support only single transactions.
*If nested transactions are supported by your database server, it is usually possible to partially commit or rollback work by using savepoints. The DB Interface Module supports this feature through the following methods:
 
RWDBConnection:setSavepoint(const RWCString& savepoint)
RWDBConnection::rollbackTransaction(const RWCString& savepoint)
You may set a savepoint anywhere within a transaction. You can later perform a partial rollback to that point, and continue on without disturbing the remainder of that transaction.
You may notice that some SQL commands require explicit transaction control for a few of our supported database vendors. Please check your DB Access Module manual for these restrictions.
NOTE: SourcePro DB does not create any transactions internally. Users are responsible for properly managing the transactions that they create.