Skip to main content

SAVEPOINT (bSQL) | Blockpoint Docs

Adds an in-memory savepoint to the current transaction.

bSQL Syntax Conventions

Syntax​

SAVEPOINT savepoint_name

Arguments​

savepoint_name
The unique name of the savepoint.

General Remarks​

  • Savepoints can be used to undo subsets of a batched transaction.
  • Savepoint names must be unique within a database, use a RELEASE SAVEPOINT command to release them.
  • Savepoints don't persist after a database recovery.

Examples​

A. Rolling back a transaction 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.

This example uses the Financial Demo Database.

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"

See Also​