top of page
CerebroSQL

PostgreSQL:  

ROLLBACK TO SAVEPOINT

ROLLBACK [ WORK | TRANSACTION ] TO [ SAVEPOINT ] savepoint_name

Example

BEGIN;

DECLARE foo CURSOR FOR SELECT 1 UNION SELECT 2;

SAVEPOINT foo;

FETCH 1 FROM foo;
?column?
----------
1

ROLLBACK TO SAVEPOINT foo;

FETCH 1 FROM foo;
?column?
----------
2

COMMIT;

bottom of page