postgresql 中的存储语句对应的查询语句
postgresql 中的存储语句对应的查询语句实在不知道如何写,里面有两个表的返回值,都分别返回一个字段代码如下:
CREATE OR REPLACE FUNCTION proGetPanelInfo(U_PID INTEGER) RETURNS SETOF RECORD AS
$$
DECLARE
v_rec RECORD;
v_rec2 RECORD;
BEGIN
FOR v_rec IN SELECT PATH FROM CfgPanel where ID=U_PID LOOP
RETURN NEXT v_rec;
END LOOP;
FOR v_rec2 IN Select PIC_PATH from CfgPanelPic where PID=U_PID LOOP
RETURN NEXT v_rec2;
END LOOP;
RETURN;
END;
$$
LANGUAGE PLPGSQL;
查询语句我如下写的:
select * from proGetPanelInfo(1::int4)t(PATH VARCHAR, PIC_PATH VARCHAR); 如何修改?
------解决方案--------------------
查询语句应该用一个字段
select * from proGetPanelInfo(1::int4) as t(PATH VARCHAR);