分页的存储过程
16lz
2022-01-19
复制代码 代码如下:
Createproceduresp_pageQuery
@sqlstrnvarchar(4000),
@page_indexint,
@page_sizeint,
@rec_countintout--
as
setnocounton
declare@cursor_idint
declare@rowcountint
execsp_cursoropen@cursor_idoutput,@sqlstr,@scrollopt=1,@ccopt=1,@rowcount=@rowcountoutput
set@rec_count=@rowcount
set@page_index=(@page_index-1)*@page_size+1
IF@rec_count>0
BEGIN
execsp_cursorfetch@cursor_id,16,@page_index,@page_size
END
ELSE
BEGIN
Select'test'='null'Where1=2
END
execsp_cursorclose@cursor_id
setnocountoff
GO
在要用的时候在那个存储过程里调用
复制代码 代码如下:
CreatePROCEDURE[dev].[P_Mobile_Comment_Page]
@course_ware_idint,
@recCountPerPageint=1,
@pageIndexint=1,
@recordCountint=0out
AS
DECLARE@sqlnvarchar(4000)
SET@sql="
Selectseg_id,course_ware_id,subject,cust_name,content,create_date
FROMT_COURSEWARE_COMMENT
Wherecourse_ware_id="+cast(@course_ware_idasvarchar(10))+"
ORDERBYseg_id"
EXECsp_Pagequery@sql,@pageIndex,@recCountPerPage,@recordCountout
GO
Createproceduresp_pageQuery
@sqlstrnvarchar(4000),
@page_indexint,
@page_sizeint,
@rec_countintout--
as
setnocounton
declare@cursor_idint
declare@rowcountint
execsp_cursoropen@cursor_idoutput,@sqlstr,@scrollopt=1,@ccopt=1,@rowcount=@rowcountoutput
set@rec_count=@rowcount
set@page_index=(@page_index-1)*@page_size+1
IF@rec_count>0
BEGIN
execsp_cursorfetch@cursor_id,16,@page_index,@page_size
END
ELSE
BEGIN
Select'test'='null'Where1=2
END
execsp_cursorclose@cursor_id
setnocountoff
GO
在要用的时候在那个存储过程里调用
复制代码 代码如下:
CreatePROCEDURE[dev].[P_Mobile_Comment_Page]
@course_ware_idint,
@recCountPerPageint=1,
@pageIndexint=1,
@recordCountint=0out
AS
DECLARE@sqlnvarchar(4000)
SET@sql="
Selectseg_id,course_ware_id,subject,cust_name,content,create_date
FROMT_COURSEWARE_COMMENT
Wherecourse_ware_id="+cast(@course_ware_idasvarchar(10))+"
ORDERBYseg_id"
EXECsp_Pagequery@sql,@pageIndex,@recCountPerPage,@recordCountout
GO
更多相关文章
- android分页查询获取系统联系人信息
- Android入门教程(三十一)------SQLite分页读取
- android ListView的分段显示、分页显示(附源码)
- android左右滑动加载分页以及动态加载数据
- Android(安卓)listview怎么实现滚动分页
- Android(安卓)ListView专题之十二 分页不同的解决方案
- Android分页控件xlistview
- android中滑动SQLite数据库分页加载
- Android(安卓)分页组件