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 TransactionsHow You Can Manage TransactionsA transaction is one or more database statements processed as a single,indivisible unit. A transaction begins with the first database statementexecuted after the application is started or after a previous commit or rollbackstatement. By default, the transaction continues until one of the followingoccurs:• An explicit commit or rollback statement occurs• A deadlock or log full error occurs• The application stopsAll locks taken during the transaction are held until the transaction iscompleted, and any changes made to a database by the transaction are notvisible to other users until the transaction is committed.How You Can Control ConcurrencyNo matter how many frames are opened or closed during a transaction, alllocks are held until the transaction is completed. It is important, therefore, todesign the application and its individual transactions to provide the bestpossible concurrency control.Concurrency control refers to the management of shared data so thatsimultaneous users can access and update the data with little or no wait timewhile data integrity is maintained.Sample Concurrency Control ApplicationIn general, data access and data integrity exist in an inverse relationship. If anapplication allows all users to access the data at will, then data integrity isseverely threatened. If the application holds locks for long periods of time, forexample by running as one continuous transaction, then it is difficult for usersto share the data. Most application developers try to find a balance that letsmultiple users access the data as quickly as possible yet maintain dataintegrity.This section presents an example application with code samples that illustratethe choices inherent in maintaining concurrency control. For instance, theapplication selects rows from a part table and, after users make their changes,updates the database. The entire application is one transaction, because thecommit statement is not executed until the table has been updated. Keeping asingle transaction throughout the application ensures data integrity, becausethe locks taken by the select statement are held until the changes arecommitted.182 <strong>Programming</strong> <strong>Guide</strong>

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

Saved successfully!

Ooh no, something went wrong!