我想在我的应用程序中实现分页。我创建了存储过程,它返回记录数作为输出参数并引用游标数据本身(带有限制和偏移量)但结果 - 我得到 - “函数结果类型必须是 bigint 因为 OUT 参数”
据我了解-它抱怨out "_count" bigint。
是否有任何情况可以从同一个存储过程中返回 参数和引用游标?
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