Skip to main content

ROLLBACK (bSQL) | Blockpoint Docs

Rolls back an explicit or implicit transaction to the beginning of the transaction, or to a savepoint inside the transaction. You can use ROLLBACK to erase all data modifications made from the start of the transaction or to a savepoint.

bSQL Syntax Conventions.

Syntax​

ROLLBACK [TO savepoint_name] 

Arguments​

savepoint_name
The name of the savepoint to be rolled back to.

Examples​

A. Rolling back a transaction.​

The following example shows the effect of rolling back a transaction. In this example, the ROLLBACK statement will roll back the INSERT statement.

This example uses the Financial Demo Database.

START TRANSACTION  
SET AUTOCOMMIT = 0
INSERT financial.companies 
VALUES ("WPG", "Washington Prime Group", "Trust")
ROLLBACK  

B. Rolling back to a savepoint.​

The following example shows the effect of rolling back a transaction to a savepoint. In this example, the ROLLBACK statement will rolls back the transaction to my first savepoint. The second insertion will be undone and while the first will persist until it is either rolled back or committed.

START TRANSACTION  
SET AUTOCOMMIT = 0
INSERT financial.companies 
VALUES ("WPG", "Washington Prime Group", "Trust")
SAVEPOINT "my first savepoint"
INSERT financial.companies VALUES ("POLA", "Polar Power, Inc", "Industrial")
ROLLBACK TO "my first savepoint"
ROLLBACK

See Also​