定义一个普通变量
最近更新时间: 2025-02-18 16:02:00
postgres=# CREATE OR REPLACE FUNCTION f25() RETURNS VOID AS
postgres-# $$
postgres$# DECLARE
postgres$# #所有变量的声明都要放在这里,建议变量以v_开头,参数以a_开头
postgres$# v_int integer := 1;
postgres$# v_text text;
postgres$# BEGIN
postgres$# v_text = 'TDSQL PG';
postgres$# RAISE NOTICE 'v_int = %',v_int;
postgres$# RAISE NOTICE 'v_text = %',v_text;
postgres$# END;
postgres$# $$
postgres-# LANGUAGE plpgsql;
CREATE FUNCTION
postgres=# SELECT f25();
NOTICE: v_int = 1
NOTICE: v_text = TDSQL PG
f25
-----
(1 row)
postgres=#