Specifying Transaction Names When Using Select

From InterBase
Jump to: navigation, search

Go Up to Understanding Data Retrieval with SELECT


InterBase enables a SQL application to run many simultaneous transactions if:

  • Each transaction is first named with a SET TRANSACTION statement.
  • Each data manipulation statement (SELECT, INSERT, UPDATE, DELETE) specifies a TRANSACTION clause that identifies the name of the transaction under which it operates.
  • SQL statements are not dynamic.

In SELECT, the TRANSACTION clause intervenes between the SELECT keyword and the column list, as in the following syntax fragment:

SELECT TRANSACTION name <col> [, <col> ...]

The TRANSACTION clause is optional in single-transaction programs or in programs where only one transaction is open at a time. It must be used in a multi-transaction program. For example, the following SELECT is controlled by the transaction, T1:

EXEC SQL
SELECT TRANSACTION T1:
COUNT(*), MAX(EMP_NO), MIN(EMP_NO), SUM(SALARY)
INTO :counter, :maxno, :minno, :total_salary
FROM EMPLOYEE;

For a complete discussion of transaction handling and naming, see Working with Transactions.