返回简单类型
最近更新时间: 2025-02-18 16:02:00
postgres=# CREATE OR REPLACE FUNCTION f9() RETURNS TEXT AS
postgres-# $$
postgres$# BEGIN
postgres$# RETURN 'TDSQL PG';
postgres$# END;
postgres$# $$
postgres-# LANGUAGE plpgsql;
CREATE FUNCTION
postgres=#
postgres=# SELECT * FROM f9() t(a_xm);
a_xm
------
TDSQL PG
(1 行记录)
postgres=#
postgres=# CREATE OR REPLACE FUNCTION f9(OUT a_xm TEXT) RETURNS TEXT AS
postgres-# $$
postgres$# BEGIN
postgres$# a_xm:='TDSQL PG';
postgres$# END;
postgres$# $$
postgres-# LANGUAGE plpgsql;
CREATE FUNCTION
postgres=#
postgres=# SELECT * FROM f9();
a_xm
------
TDSQL PG
(1 行记录)
#上面两个函数其实就是同一个函数,建立时如果不加OR REPLACE则会提示已经存在
postgres=# CREATE OR REPLACE FUNCTION f10() RETURNS TEXT[] AS
postgres-# $$
postgres$# BEGIN
postgres$# RETURN ARRAY['TDSQL PG','pgxz'];
postgres$# END;
postgres$# $$
postgres-# LANGUAGE plpgsql;
CREATE FUNCTION
postgres=#
postgres=# SELECT * FROM f10();
f10
---------------
{TDSQL PG,pgxz}
(1 行记录)