Error handling for transactions

When Dexterity performs ordinary table operations for Microsoft SQL Server, it automatically uses transactions for each operation. It also handles any errors that occur during the table operations, such as deadlocks. If you use transactions in your application, you are responsible for handling any errors that occur. To make handling errors easier, use the exception handling capability available in Dexterity. Exception handling is described in detail in Structured Exception Handler.

The most common recoverable error that occurs when using a transaction is a deadlock. A deadlock occurs when two users, each having locked a record, attempt to lock the other user’s record. Each user waits for the other to release the lock. If a deadlock occurs, an exception will be thrown that your application will need to handle.

To deal with exceptions, transactions are executed within a try...end try block. If a deadlock occurs, the pending transaction will automatically be rolled back. An exception will be thrown and caught by the exception handler, which will typically contain code to wait for a specified amount of time, then try the transaction again. The template code provided in the next section shows how a typical transaction is structured.


Documentation Feedback