Transact-SQL transaction mode

In this optional Transaction mode, the Embedded SQL syntax is the same as that used in Transact-SQL. The begin transaction statement explicitly initiates transactions.

The syntax of the Embedded SQL transaction statements is:

exec sql [at  connect_name ]  
     begin transaction [ transaction_name ];

exec sql [at  connect_name]  
     save transaction [ savepoint_name]; 

exec sql [at  connect_name] commit transaction  
     [ transaction_name ];

exec sql [at  connect_name] rollback transaction  
     [ savepoint_name  |  transaction_name ];

NoteThe disconnect command rolls back all open transactions. For details on this statement, see Chapter 5, “Connecting to Adaptive Server.”

When you issue a begin transaction on a connection, you must also issue a save, commit, or roll back transaction on the same connection. Otherwise, an error is generated.