行类型

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

  • 复制
    复制成功
postgres=# create table public.t(id int,mc text);
CREATE TABLE
postgres=#
postgres=# CREATE OR REPLACE PROCEDURE p_row (a_row public.t)  AS
$$
BEGIN
    RAISE NOTICE 'id = % ; mc = %',a_row.id,a_row.mc;
END;
$$
LANGUAGE PLPGSQL;
CREATE PROCEDURE
postgres=# CALL p_row(ROW(1,'TBase'));
NOTICE:  id = 1 ; mc = TBase
CALL
postgres=#
  • 行数组。
  • 复制
    复制成功
postgres=# CREATE OR REPLACE PROCEDURE p_row_array (a_rec public.t[]) AS
$$
BEGIN
    RAISE NOTICE 'a_rec = %',a_rec;
    RAISE NOTICE 'a_rec[1].id = %',a_rec[1].id;
END;
$$
LANGUAGE PLPGSQL;
CREATE PROCEDURE
postgres=# CALL p_row_array(array[row(1,'TBase'),row(1,'pgxz')]::public.t[]);
NOTICE:  a_rec = {"(1,TBase)","(1,pgxz)"}
NOTICE:  a_rec[1].id = 1
CALL
postgres=#