USING Clause

From InterBase

Go Up to Specifying SET TRANSACTION Behavior


Every time a transaction is started, InterBase reserves system resources for each database currently attached for program access. In a multi-transaction, ­multi-database program, the USING clause can be used to preserve system resources by restricting the number of open databases to which a transaction has access. USING restricts an access of a transaction to tables to a listed subset of all open databases using the following syntax:

EXEC SQL
SET TRANSACTION [NAME name]
[READ WRITE | READ ONLY]
[WAIT | NO WAIT]
[[ISOLATION LEVEL] {SNAPSHOT [TABLE STABILITY]
| READ COMMITTED [[NO] RECORD_VERSION]}]
USING dbhandle> [, dbhandle ...];
Important:
A single SET TRANSACTION statement can contain either a USING or a RESERVING clause, but not both.

The following C program fragment opens three databases, test.ib, research.ib, and employee.ib, assigning them to the database handles TEST, RESEARCH, and EMP, respectively. Then it starts the default transaction and restricts its access to TEST and EMP:

. . .
EXEC SQL
SET DATABASE ATLAS = 'test.ib';
EXEC SQL
SET DATABASE RESEARCH = 'research.ib';
EXEC SQL
SET DATABASE EMP = 'employee.ib';
EXEC SQL
CONNECT TEST, RESEARCH, EMP; /* Open all databases */
EXEC SQL
SET TRANSACTION USING TEST, EMP;
. . .

Advance To: