ALLBASE/SQL Reference Manual (36216-90216)

98 Chapter2
Using ALLBASE/SQL
Using Multiple Connections and Transactions with Timeouts
The following general example shows how to set user timeout values:
1. Put multi-transaction mode in effect.
SET MULTITRANSACTION ON
2. Connect to the PartsDBE DBEnvironment.
CONNECT TO 'PartsDBE' AS 'Parts1'
3. Set the timeout value for the PartsDBE connection to an appropriate number of
seconds. In this case, the application will wait five minutes for system resources when
accessing the PartsDBE DBEnvironment.
SET USER TIMEOUT 300 SECONDS
4. Connect to the SalesDBE DBEnvironment.
CONNECT TO 'SalesDBE' AS 'Sales1'
5. Set the timeout value for the SalesDBE connection to an appropriate number of
seconds. In this case, your application will wait 30 seconds for system resources when
accessing the SalesDBE DBEnvironment.
SET USER TIMEOUT 30 SECONDS
6. Set the current connection to Parts1.
SET CONNECTION 'Parts1'
7. Begin a transaction for PartsDBE. If this transaction waits for system resources more
than five minutes, it will time out and return an error message.
BEGIN WORK RC
SELECT PartNumber, PartName, SalesPrice
FROM PurchDB.Parts
WHERE PartNumber BETWEEN 20000 AND 21000
If DBERR 2825 is returned, the transaction has timed out, and your application must
take appropriate action.
.
.
.
8. Set the current connection to Sales1.
SET CONNECTION 'Sales1'
9. Begin a transaction for SalesDBE. If this transaction waits for system resources more
than 30 seconds, it will timeout and return an error message to the application.
BEGIN WORK RC
BULK SELECT PartNumber, Sales
FROM Owner.Sales
WHERE PartNumber = '1123-P-20'
AND SaleDate BETWEEN '1991-01-01' AND '1991-06-30'