ALLBASE/SQL Reference Manual (36216-90216)

Chapter 2 99
Using ALLBASE/SQL
Using Multiple Connections and Transactions with Timeouts
.
.
.
If DBERR 2825 is returned, the transaction has timed out, and you must take
appropriate action.
Further discussion of timeout functionality is provided in the ALLBASE/SQL Advanced
Application Programming Guide.
Setting the Transaction Mode
The SET MULTITRANSACTION statement allows you to switch between single-transaction
mode and multi-transaction mode.Single-transaction mode implies sequential execution of
transactions across a set of DBEnvironment connections. When your application requires
multiple, simultaneous transactions, you must choose multi-transaction mode.
WARNING
When using multi-transaction mode, be sure the current timeout
value for all connections is set to a value other than NONE (infinity).
This eliminates the possibility of an infinite wait if an undetectable
deadlock or wait condition occurs.
Using Single-Transaction Mode
If your application contains queries for two or more databases and you want to
sequentially execute a single transaction against each database, you can use
single-transaction mode. This mode is the default and is standards compliant. The
following example illustrates the use of single-transaction mode in ISQL:
1. Put single-transaction mode in effect.
isql=> SET MULTITRANSACTION OFF;
2. Connect to two DBEnvironments.
isql=> CONNECT TO 'PartsDBE' AS 'Parts1';
isql=> CONNECT TO 'SalesDBE' AS 'Sales1';
3. Set the current connection to Parts1.
isql=> SET CONNECTION 'Parts1';
4. Begin a transaction for PartsDBE.
isql=> BEGIN WORK RC;
isql=> SELECT PartNumber, PartName, SalesPrice
> FROM PurchDB.Parts
> WHERE PartNumber BETWEEN 20000 AND 21000;
.
.
.