前台不能返回存储过程的 output 参数,怪怪。

coffeewar coffeewar 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
存储过程是邹键的分页存储过程,其它好像都正常,可是 output参数@pageCount在前台却不能返回,总是产生异常,提示 @pageCount为空。
存储过程如下:
ALTER procedure p_splitpage
--@sql nvarchar(4000), --要执行的sql语句
@depId tinyint,
@cateId tinyint=null,
@currentpage int=1, --要显示的页码
@pagesize int=16, --每页的大小
@pagecount int=0 out --总页数
as
set nocount on
declare @p1 int
declare @sql varchar(4000)
if(@cateId is not null and @cateId!=0)
set @sql='select productId,productName,productStandard,retailPrice,normalPicture
from product where departmentId='+cast(@depId as varchar)+' and categoryId='+cast(@cateId as varchar)
else
set @sql='select productId,productName,productStandard,retailPrice,normalPicture
from product where departmentId='+cast(@depId as varchar)
exec sp_cursoropen @p1 output,@sql,@scrollopt=1,@ccopt=1,@rowcount=@pagecount output

select @pagecount=ceiling(1.0*@pagecount/@pagesize)
,@currentpage=(@currentpage-1)*@pagesize+1
select @currentpage
exec sp_cursorfetch @p1,16,@currentpage,@pagesize
exec sp_cursorclose @p1
...全文
评论 4
收藏 已收藏
分享
返回顶部
coffeewar
MS-SQL Server 34,876 成员 254,635 内容