RAISE EXCEPTION 自定义ERRCODE
最近更新时间: 2024-10-17 17:10:00
postgres=# CREATE OR REPLACE PROCEDURE p_exception_errcode() AS
$$
DECLARE
v_int INTEGER := 1;
BEGIN
RAISE EXCEPTION ' 程序EXCEPTION ' USING ERRCODE = '23505';
END;
$$
LANGUAGE plpgsql;
CREATE PROCEDURE
postgres=# CALL p_exception_errcode();
ERROR: 程序EXCEPTION
CONTEXT: PL/pgSQL function p_exception_errcode() line 5 at RAISE
postgres=#
#日志中会记录这个ERRCODE
2021-04-25 11:25:25.958 CST,"tbase","postgres",30486,coord(30486,135876),"172.16.64.8:62252",6084c50a.7716,coord(30486,135876),91,"CALL",2021-04-25 09:25:30 CST,11/135876,0,ERROR,23505," 程序EXCEPTION ",,,,,"PL/pgSQL function p_exception_errcode() line 5 at RAISE","CALL p_exception_errcode();",,,"psql"