SET TRANSACTION

Advantage SQL Engine

Sets the autocommit state for transactions on the server.

Syntax

SET TRAN[SACTION] AUTOCOMMIT_ON | AUTOCOMMIT_OFF | EXPLICIT

Remarks

The AUTOCOMMIT feature allows a transaction to be automatically begun and/or committed around the execution of a DML (Data Manipulation Language) SQL statement. With AUTOCOMMIT_ON, any INSERT, UPDATE, or DELETE statement would have a transaction begun before it and committed after its completion. With AUTOCOMMIT_OFF, any INSERT, UPDATE, or DELETE statement would have a transaction begun before it but not committed or rolled back after its completion (it is the user’s responsibility to commit or rollback the transaction at a later time). The EXPLICIT option simply returns the transaction state to its default state of requiring the user to explicitly begin, commit, and rollback all transactions.

Note Beginning a transaction explicitly sets the AUTOCOMMIT mode to explicit. The AUTOCOMMIT state of a user cannot be altered while inside a transaction.

Examples

SET TRANSACTION AUTOCOMMIT_ON

UPDATE sal SET salary = 35000.00 WHERE emp_id = 25089

 

SET TRANSACTION AUTOCOMMIT_OFF

UPDATE sal SET salary = 20000 WHERE hire_date < '1992-02-14'

COMMIT WORK

 

SET TRAN EXPLICIT

DELETE FROM customer WHERE purch_amt < 100.00 AND NOT state = ‘CA’

ROLLBACK WORK