RAISE EXCEPTION 自定义ERRCODE
最近更新时间: 2024-10-17 17:10:00
postgres=# CREATE OR REPLACE FUNCTION f28() RETURNS VOID AS
postgres-# $$
postgres$# DECLARE
postgres$# v_int INTEGER := 1;
postgres$# BEGIN
postgres$# RAISE EXCEPTION ' 程序EXCEPTION ' USING ERRCODE = '23505';
postgres$# END;
postgres$# $$
postgres-# LANGUAGE plpgsql;
CREATE FUNCTION
postgres=# SELECT f28();
ERROR: 程序EXCEPTION
#日志中会记录这个ERRCODE
2017-10-03 18:40:16.710 CST,"pgxz","postgres",15072,"[local]",59d33b65.3ae0,225,"idle",2017-10-03 15:25:25 CST,4/367159,0,LOG,00000,"statement: SELECT f28();",,,,,,,,,"psql"
2017-10-03 18:40:16.710 CST,"pgxz","postgres",15072,"[local]",59d33b65.3ae0,226,"SELECT",2017-10-03 15:25:25 CST,4/367159,0,ERROR,23505," 程序EXCEPTION ",,,,,,,,,"psql"