首页 > 解决方案 > 保存点和回滚在 postgresql 脚本中不起作用

问题描述

我在下面的 pg 脚本中使用保存点和回滚。低于错误。

错误:PL/pgSQL 中不支持的事务命令

请帮助我如何实现这一目标。

do
$block$ 
declare
BEGIN
 perform updatecustdtls (
                  custdes               => 'initial state',         
                  custno            => 'C1122',
                  cmd       =>  TO_TIMESTAMP('11/21/2005','dd/mm/yyyy')::TIMESTAMP(0),
                  );   


 savepoint updatecust;                         

update custd set custid = 9 where custno = 'C1122';


    perform updatecustdtls (
                  custdes               => 'middle state',         
                  custno            => 'C4455',
                  cmd       =>  TO_TIMESTAMP('11/11/2006','dd/mm/yyyy')::TIMESTAMP(0),
                  );

rollback to updatecust;  

    perform updatecustdtls (
                  custdes               => 'final state',         
                  custno            => 'C88809',
                  cmd       =>  TO_TIMESTAMP('08/15/2007','dd/mm/yyyy')::TIMESTAMP(0),
                  );

end $block$; 

提前致谢。

标签: postgresql

解决方案


推荐阅读