返回行类型
最近更新时间: 2025-02-18 16:02:00
postgres=# \d t
资料表 "public.t"
栏位 | 型别 | 修饰词
------+---------+--------
id | integer |
mc | text |
postgres=# CREATE OR REPLACE FUNCTION f13() RETURNS public.t AS
postgres-# $$
postgres$# DECLARE
postgres$# v_rec public.t%ROWTYPE;
postgres$# BEGIN
postgres$# SELECT * INTO v_rec FROM public.t LIMIT 1;
postgres$# RETURN v_rec;
postgres$# END;
postgres$# $$
postgres-# LANGUAGE plpgsql;
CREATE FUNCTION
postgres=#
postgres=# SELECT * FROM f13();
id | mc
----+------
1 | TDSQL PG
(1 行记录)
postgres=# CREATE OR REPLACE FUNCTION f14() RETURNS public.t[] AS
postgres-# $$
postgres$# DECLARE
postgres$# v_rec public.t[];
postgres$# BEGIN
postgres$# SELECT ARRAY[ROW(t.*),ROW(t.*)]::public.t[] INTO v_rec FROM public.t LIMIT 1;
postgres$# RETURN v_rec;
postgres$# END;
postgres$# $$
postgres-# LANGUAGE plpgsql;
CREATE FUNCTION
postgres=#
postgres=# SELECT * FROM f14();
f14
-------------------------
{"(1,TDSQL PG)","(1,TDSQL PG)"}
(1 行记录)