Rolls a transaction back to a savepoint inside the transaction or to the beginning of the transaction.
exec sql [at connection_name] rollback [transaction | tran | work] [transaction_name | savepoint_name] end-exec
The keywords transaction, trans, and work are interchangeable in the rollback statement, but only work is ANSI-compliant.
The name of the transaction being rolled back.
The name assigned to the savepoint in a save transaction statement. If you omit savepoint_name, SQL Server rolls back the entire transaction.
...
EXEC SQL CONNECT "user" IDENTIFIED BY "password"
AT connect1 USING "srvname" END-EXEC.
...
EXEC SQL AT connect1 UPDATE test SET col1 = 'x' END-EXEC.
IF SQLCODE = 0
DISPLAY "ROWS UPDATED = ",SQLERRD(3)
ELSE
DISPLAY "AN ERROR OCCURED -",SQLERRMC
ESQL SQL AT connect1 ROLLBACK TRANSACTION END-EXEC
END-IF.
This reference page mainly describes aspects of the Transact-SQL rollback statement that differ when used with Embedded SQL. See the Adaptive Server Enterprise Reference Manual for more information about the rollback statement, savepoints, and Transact-SQL transaction management.
Transaction names and savepoint names must conform to the Transact-SQL rules for identifiers.
Transaction names and savepoints are Transact-SQL extensions; they are not ANSI-compliant. Do not use a transaction name or savepoint name with the ANSI-compliant keyword work.
begin transaction, commit