开发者社区> 问答> 正文

mssql 本地测试没问题 阿里云服务器报错?报错

CREATE  procedure [dbo].[SqlPager]
@sqlstr nvarchar(4000), --查询字符串
@currentpage int, --第N页
@pagesize int --每页行数
as
set nocount on
declare @P1 int, --P1是游标的id
 @rowcount int
exec sp_cursoropen @P1 output,@sqlstr,@scrollopt=1,@ccopt=1, @rowcount=@rowcount output
select ceiling(1.0*@rowcount/@pagesize) as TotalPage,@rowcount as TotalCount,@currentpage as CurrentPage 
set @currentpage=(@currentpage-1)*@pagesize+1
exec sp_cursorfetch @P1,16,@currentpage,@pagesize 
exec sp_cursorclose @P1
set nocount off





错误信息  The cursor was not declared. sp_cursorfetch: The cursor identifier value provided (0) is not valid. sp_cursorclose: The cursor identifier value provided (0) is not valid.

展开
收起
爱吃鱼的程序员 2020-06-12 14:40:31 737 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    问题可能出在执行sp_cursoropen失败了,你查看下它的返回值

    如果不是0,那么就是出错了

    https://msdn.microsoft.com/en-us/library/ff848737.aspx

    2020-06-12 14:40:49
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
如何运维千台以上游戏云服务器 立即下载
网站/服务器取证 实践与挑战 立即下载
ECS计算与存储分离架构实践 立即下载