10.07.2015 Views

Programming Guide - Actian

Programming Guide - Actian

Programming Guide - Actian

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

How You Can Manage TransactionsSimilarly, if you set the DBHandle attribute of either a bitmap or StringObjectobject, you access the database. Setting the DBHandle can initiate atransaction, and commit and rollback statements affect the statements that seta DBHandle attribute.For more information about setting a DBHandle directly, see How You Can Usethe ErrorStatus Attribute (see page 201). For more information aboutdetecting and handling DBMS errors in DataStream objects, see How You CanHandle DataStream Errors (see page 199).How You Can Manage Transaction ErrorsDeadlock and log file full errors cause the system to roll back the entiretransaction. By default, other errors only roll back the statement that causedthe error. If you want to roll back an entire transaction whenever any databaseerror occurs, you must explicitly issue the rollback statement.If you want the entire transaction rolled back in case of error, instead ofwriting code that handles each statement separately, you can set transactionmanagement for the entire session using the SQL set session with on_errorstatement. In addition to requiring less code, this statement requires fewerwrites to the log file.For example, to ensure that every transaction in the Videos application isrolled back in the event of any database error, the application's top frame (themain_control frame) includes the following statement:set session with on_error = rollback transaction;To turn off this option, causing rollback of only the current databasestatement, issue the following statement:set session with on_error = rollback statement;For more information about determining the status of the current transaction,see How You Can Use the Inquire_sql Statement (see page 201).How Running with Autocommit On WorksAutocommit on describes a transaction management state in which eachdatabase statement is an individual transaction automatically committed whenit is successfully executed. By default, autocommit is off. To turn autocommiton, use DBSessionObject's SetAutoCommit method.Working with a Database 187

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!