我在postgres中有一个函数,它返回setof类型
ctrlr_kpi_type
.
CREATE TYPE public.ctrlr_kpi_type AS
(
door_id text,
email text,
android_id text,
api_level integer,
app_vers numeric,
lattitude numeric,
longitude numeric,
oper_cd text,
firmware_logic_ver text,
safety_logic integer,
hold_beam_type integer,
sys_cycle_count integer,
ctrlr_cycle_count integer,
error_name text,
powered_up_days integer,
m1_err_cnt integer,
m1_err_cycle_cnt integer,
m2_err_cnt integer,
m2_err_cycle_cnt integer,
etl_insert_ts timestamp without time zone,
reading_date timestamp without time zone,
sap_equip_nbr text
);
函数如下:
CREATE OR REPLACE FUNCTION public.controller_kpi(
start_date date,
end_date date)
RETURNS SETOF ctrlr_kpi_type
LANGUAGE 'plpgsql'
..............
当我使用
select controller_kpi('2018-05-01', '2018-05-31')
,它返回类型的列表
Ctrlr_kpi_类型
. 但是,它显示为一列。
如何根据属性将类型分成列,以便将结果保存到表中,然后导出到csv?