【发布时间】:2015-05-11 14:03:31
【问题描述】:
我想在我的应用程序中实现分页。 我创建了存储过程,它返回记录数作为输出参数和引用游标数据本身(带有限制和偏移量) 但作为结果 - 我得到 -" 由于 OUT 参数,函数结果类型必须是 bigint"
据我了解 - 它抱怨 out "_count" bigint。
有什么情况可以从同一个存储过程中返回out参数和ref cursor?
CREATE OR REPLACE FUNCTION aggr."GetPromotionsFull"("_limit" bigint, "_offset" bigint, out "_count" bigint)
RETURNS refcursor AS
$BODY$
DECLARE
ref refcursor;
BEGIN
select count(1) into "_count" from aggr."Promotion" t
inner join aggr."Company" c on t."CompanyId"=c."Id"
where
t."isDeleted"=false
and c."isDeleted"=false;
OPEN ref FOR
SELECT t."Id",
t."CompanyId",
t."PromoName",
t."Description",
t."Url",
t."ImgPath",
t."CreatedDate",
t."IsEnabled",
t."isDeleted",
c."Name"as "CompanyName"
FROM aggr."Promotion" t
inner join aggr."Company" c on t."CompanyId"=c."Id"
where
t."isDeleted"=false
and c."isDeleted"=false
limit "_limit" offset "_offset";
RETURN ref;
END
$BODY$
LANGUAGE plpgsql VOLATILE
【问题讨论】:
标签: postgresql stored-procedures plpgsql out-parameters ref-cursor