Adaptive Server supports these transaction modes:
chained mode implicitly begins a transaction before any data-retrieval or modification statement: delete, insert, open, fetch, select, and update. You must still explicitly end the transaction with commit transaction or rollback transaction.
The default mode, called unchained mode or Transact-SQL mode, requires explicit begin transaction statements paired with commit transaction or rollback transaction statements to complete the transaction.
You can set either mode using the chained option of the set command. However, do not mix these transaction modes in your applications. The behavior of stored procedures and triggers can vary, depending on the mode, and you may require special action to run a procedure in one mode that was created in the other.
The SQL standards require every SQL data-retrieval and data-modification statement to occur inside a transaction, using chained mode. A transaction automatically starts with the first data-retrieval or data-modification statement after the start of a session or after the previous transaction commits or aborts. This is the chained transaction mode.
You can set this mode for your current session by turning on the chained option of the set statement:
However, you cannot execute the set chained command within a transaction. To return to the unchained transaction mode, set the chained option to off.
The following group of statements produce different results, depending on which mode you use:
insert into publishers values ("9906", null, null, null) begin transaction delete from publishers where pub_id = "9906" rollback transaction
In unchained transaction mode, rollback affects only the delete statement, so publishers still contains the inserted row. In chained mode, the insert statement implicitly begins a transaction, and the rollback affects all statements up to the beginning of that transaction, including the insert.
All application programs and ad hoc user queries should address the correct transaction mode. The transaction mode you use depends on whether or not a particular query or application requires compliance to the SQL standards. Applications that use chained transactions (for example, the Embedded SQL precompiler) should set chained mode at the beginning of each session.