我一直在postgres中使用或多或少这样的东西来模拟如何在SQL Server中使用Try/Catch块,如果发现错误,可以在Catch中回滚事务:
do $$
begin
[SQL here]
exception when others then
raise notice 'Error in insert statement ---> % %', SQLERRM, SQLSTATE LINE;
end;
$$ language 'plpgsql';
Run Code Online (Sandbox Code Playgroud)
有没有办法报告发生错误的行,如"ERROR_LINE()?
提前致谢