RAISE NOTICE

最近更新时间: 2024-06-12 15:06:00

postgres=# CREATE OR REPLACE FUNCTION f28() RETURNS VOID AS
postgres-# $$    
postgres$# DECLARE
postgres$#     v_int INTEGER := 1;
postgres$# BEGIN           
postgres$#     RAISE NOTICE 'v_int = %, 随机数 = %',v_int,random();
postgres$# END;
postgres$# $$
postgres-# LANGUAGE plpgsql;
CREATE FUNCTION
postgres=# SELECT f28();
NOTICE:  v_int = 1, 随机数 = 0.236714988015592
 f28 
-----
(1 row)

使用raise notice 向终端输出一个消息,也有可能写到日志中(需要调整日志的保存级别)。