create or replace procedure usp_GetMyPhotos
@pageIndex int, --当前页码
@pageSize int, --每页多少条
@pageCount int output --计算 总共多少页
as
declare @count int, --总共多少条
select @count =COUNT(*) from TB_PROCURECATALOG,
set @pageCount = CEILING( @count*1.0/@pageSize)
select * from
(select A.*,rownum RN FROM
(SELECT * from tb_procurecatalog ORDER BY PROCURECATALOGID)A
)
where num between @pageSize*(@pageIndex-1) + 1 and @pageSize*@pageIndex
测试:
declare @n int,
exec usp_GetMyPhotos 1,3,@n output
print @n