云数据库 GAUSSDB-ROLLBACK TO SAVEPOINT:示例

时间:2024-01-23 20:09:19

示例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
--撤销 my_savepoint 建立之后执行的命令的影响。
postgres=# START TRANSACTION;
postgres=# SAVEPOINT my_savepoint;
postgres=# ROLLBACK TO SAVEPOINT my_savepoint;
--游标位置不受保存点回滚的影响。
postgres=# DECLARE foo CURSOR FOR SELECT 1 UNION SELECT 2;
postgres=# SAVEPOINT foo;
postgres=# FETCH 1 FROM foo;
 ?column? 
----------
        1
postgres=# ROLLBACK TO SAVEPOINT foo;
postgres=# FETCH 1 FROM foo;
 ?column? 
----------
        2
postgres=# RELEASE SAVEPOINT my_savepoint;
postgres=# COMMIT;
support.huaweicloud.com/devg-v1-gaussdb/gaussdb_devg_0631.html