如何在Postgresql上实现`BEGIN ATOMIC`

时间:2018-11-20 13:37:28

标签: postgresql postgresql-11

有人知道Postgresql中的Sybase BEGIN ATOMIC 等效吗?

应该是这样的:

create or replace function my_func()
returns int
as $$ 
begin 
    begin atomic
        update stetment1;
        update stetment2;
        update stetment3;
    end;
end;
$$ LANGUAGE PLPGSQL;

三个更新语句必须要么全部成功要么全部失败。

0 个答案:

没有答案