返回RECORD类型

最近更新时间: 2025-02-18 16:02:00

  • 复制
    复制成功
postgres=# CREATE OR REPLACE FUNCTION f15() RETURNS RECORD AS
postgres-# $$
postgres$# DECLARE
postgres$#     v_rec RECORD;
postgres$# BEGIN
postgres$#     v_rec:=ROW(1::integer,'TBase'::text,'pgxz'::text);
postgres$#     RETURN v_rec;
postgres$# END;
postgres$# $$
postgres-# LANGUAGE plpgsql;
CREATE FUNCTION
postgres=# SELECT f15();
       f15
-----------------
 (1,TDSQL PG,pgxz)
(1 行记录)
postgres=# SELECT * FROM f15() t(id integer,xm text,xl text);
 id |  xm  |   xl
----+------+--------
  1 | TDSQL PG | pgxz
(1 行记录)