欢迎光临
我们一直在努力

关于分页办法

建站超值云服务器,限时71元/月

时间关系,没有经过完全测试,这个是大概意思。

create procedure getnotes

@forumid varchar(10),

@a_intpageno int ,

@a_intpagesize int,

@rootid varchar(10)

as

declare @m_intrecordnumber int

declare @m_intstartrecord int

declare @pagecount int

declare @temp int

declare @end int

declare @sql varchar(500)

declare @bbsname varchar(25)

declare @articles int

declare @manager varchar(30)

declare @selectrootid varchar(500)

declare @temprootid varchar(10)

select @m_intrecordnumber = @a_intpagesize * @a_intpageno

select @m_intstartrecord = @a_intpagesize * (@a_intpageno – 1) + 1

set nocount on

select @bbsname=subjectname,@manager=manager,@articles=articles from bbs_subjects where subjectid=@forumid

if @rootid=0

begin

— select @sql=declare m_curtemp scroll cursor for select id,title,shrink,rootid,orderid,pubtime,hits,bytes,username,email from bbs_forum_+@forumid+ where rootid in (select distinct rootid from bbs_forum_+@forumid+ ) order by rootid desc,orderid asc

select @sql=declare m_curtemp scroll cursor for select rootid from bbs_forum_+@forumid+ where rootid=parentid order by rootid desc

end

else

select @sql=declare m_curtemp scroll cursor for select id,title,shrink,rootid,orderid,pubtime,hits,bytes,username,email from bbs_forum_+@forumid+ where rootid=+@rootid+ order by orderid asc

exec(@sql)

open m_curtemp

set @pagecount = case

when @@cursor_rows % @a_intpagesize=0 then @@cursor_rows / @a_intpagesize

when @@cursor_rows % @a_intpagesize<>0 then @@cursor_rows / @a_intpagesize+1

end

if @@cursor_rows<@a_intpagesize and @@cursor_rows>0

begin

select @pagecount=1

end

if @rootid=0

begin

set @temp = 1

set @selectrootid=0

fetch absolute @m_intstartrecord from m_curtemp into @temprootid

while @@fetch_status = 0 and @temp < @a_intpagesize

begin

set @temp = @temp + 1

select @selectrootid=@selectrootid+,+@temprootid

fetch next from m_curtemp into @temprootid

end

close m_curtemp

deallocate m_curtemp

set nocount off

select pagecount = @pagecount

select bbsname=@bbsname

select manager=@manager

select articles=@articles

select @sql=declare curtemp scroll cursor for select id,title,shrink,rootid,orderid,images,pubtime,hits,bytes,username,email from bbs_forum_+@forumid+ where rootid in (+@selectrootid+) order by rootid desc,orderid asc

exec(@sql)

open curtemp

fetch first from curtemp

while @@fetch_status = 0

begin

fetch next from curtemp

end

close curtemp

deallocate curtemp

end

else

begin

set @temp = 1

set nocount off

fetch absolute @m_intstartrecord from m_curtemp

while @@fetch_status = 0 and @temp < @a_intpagesize

begin

set @temp = @temp + 1

fetch next from m_curtemp

end

close m_curtemp

deallocate m_curtemp

end

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 关于分页办法
分享到: 更多 (0)