PostgreSQL 调用存储过程返回结果集

创建返回结果集类型的存储过程:

CREATE OR REPLACE FUNCTION public.f_get_member_info(
 id integer,
 productname character)
    RETURNS SETOF record
    LANGUAGE 'plpgsql'

COST 100
    VOLATILE
    ROWS 1000
AS $BODY$

DECLARE
 rec record;
BEGIN
 for rec in EXECUTE 'select id, "productName" from "Products";'
    loop
    return next rec;
    end loop;

return;
END;

$BODY$;

ALTER FUNCTION public.f_get_member_info(integer, character)
    OWNER TO postgres;

如何调用存储过程返回结果集: 

select * from f_get_member_info(4, 1, '', 'xxxx')
as member(member_num text,mname text,name text,discount_rate real,account numeric(16,2),integral int,phone text,birthday date,qq int,email text,onAccount int,status int,address text,tip text,start_date date,valid_date int,store_nam text);

上一篇:关于使用Tomcat服务器出现413错误的解决办法(Request Entity Too Large)


下一篇:mysql 函数 时间函数,数学函数,字符串函数,条件判断函数