如何在下面的查询中的表格上插入异常消息
do $$
begin
Select (2 / 0)
exception when others then
RAISE INFO 'Error Name:%',SQLERRM;
RAISE INFO 'Error State:%', SQLSTATE;
Insert into TB_ERRORLOG(msg) values('Error =' || SQLERRM || SQLSTATE);
END;
$$ language 'plpgsql';
答案 0 :(得分:0)
以下是固定的声明。
DO $$
BEGIN
SELECT (2 / 0);
EXCEPTION WHEN others THEN
RAISE INFO 'Error Name:%',SQLERRM;
RAISE INFO 'Error State:%', SQLSTATE;
INSERT INTO TB_ERRORLOG(msg) VALUES ('Error =' || SQLERRM || SQLSTATE);
END;
$$ language plpgsql;