发生异常时,我有问题要引起注意。 可以说我的查询有两个inserts语句。
do $$
begin
insert into ...
insert into ...
exception when others then
raise notice '% %', SQLERRM, SQLSTATE;
end; $$
language 'plpgsql';
我想返回错误消息和代码。 目前没有任何反应。如果删除了'notice'%%',SQLERRM,SQLSTATE;' 然后引发错误,但我需要抓住它。似乎“通知”无效。 这就是我的回应
{"command":"BEGIN","rowCount":null,"oid":null,"rows":[],"fields":[],"_parsers":[],"RowCtor":null,"rowAsArray":true}
{"command":"LOCK","rowCount":null,"oid":null,"rows":[],"fields":[],"_parsers":[],"RowCtor":null,"rowAsArray":true}
{"command":"DO","rowCount":null,"oid":null,"rows":[],"fields":[],"_parsers":[],"RowCtor":null,"rowAsArray":true}
{"command":"COMMIT","rowCount":null,"oid":null,"rows":[],"fields":[],"_parsers":[],"RowCtor":null,"rowAsArray":true}
Postgres 9.4