Cancel a transaction.

 

Syntax

 

<rollback statement> ::= ROLLBACK [ WORK ]

 

 

Usage

 

The ROLLBACK statement terminates the active transaction and cancels all changes made during the transaction.

 

 

Notes

 

The COMMIT statement will return an error if no transaction is active.



 

 

Examples

 

1)

The following example cancels the current transaction:



 


ROLLBACK;



 

2)

The following example shows the ROLLBACK statement used in the context of a TRY statement:



 


START TRANSACTION;


TRY




// Execute some data-change statements here.


COMMIT;




CATCH POSITION( 'Unable to open table' IN ERROR_MESSAGE ) <> 0




ROLLBACK;


SIGNAL ERROR_MESSAGE;




END;



 

 


 

Conformance

 

SQL:2003 standard

-

Core SQL