我在Postgres数据库中有一个匿名的DO块,如下所示:
@H_502_10@
使用RAISE NOTICE语句
DO LANGUAGE plpgsql $$ DECLARE FUNC_ID smallint; BEGIN SELECT COUNT(1) INTO FUNC_ID FROM FUNCTION WHERE NAME = 'addition'; IF FUNC_ID = 0 THEN INSERT INTO FUNCTION ( ID,NAME,DESCRIPTION,FUNCTION) values ((select (max(id)+1) from FUNCTION),'subtraction','calculate','catalog'); END IF; END; $$;
postgres=# DO $$BEGIN RAISE NOTICE 'Hello %',SESSION_USER; END; $$; NOTICE: Hello pavel DO
请参阅相关的documentation.