sybase分页存储过程的实现

sybase分页存储过程应该如何实现呢?这是很多人都提到的问题,下面就为您介绍sybase分页存储过程的写法,希望可以让您对sybase分页存储过程有更多的了解。

十载的广汉网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。营销型网站的优势是能够根据用户设备显示端的尺寸不同,自动调整广汉建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联公司从事“广汉网站设计”,“广汉网站推广”以来,每个客户项目都认真落实执行。

 
 
 
  1. create procedure SP_PHP_PAGE @qry varchar(16384),@iStart int, @iLimit int, @sKeyFiled  varchar(32) as 
  2. /*@qry SQL语句, @iStart 开始, @iLimit 结束,@sKeyFiled 表中的主键 */
  3. begin
  4. declare @execsql varchar(16384)
  5. declare @execsqltmp varchar(16384)
  6. /*定义临时表表名*/
  7. declare @dt varchar(10) --生成临时表的随机数
  8. set @dt=substring(convert(varchar, rand()), 3, 10)   --一个字符型的随机数
  9. set rowcount @iLimit   
  10. if(@sKeyFiled is null)
  11. begin    
  12. set @execsql = stuff(@qry,charindex('select',@qry),6,'select number(*) as sybid,')           
  13. set @execsqltmp = ' select * from #temptable' + @dt + ' where sybid>' || convert(varchar,@iStart) || ' and sybid <= ' || convert(varchar,(@iStart/@iLimit+1)*@iLimit)  
  14. end
  15. else
  16. begin
  17. set @execsql = stuff(@qry,charindex('select',@qry),6,'select number(*) as sybid,' || @sKeyFiled || ' ,@' )          
  18. set @execsql =  stuff(@execsql,charindex(',@',@execsql),charindex('from',@execsql)-charindex(',@',@execsql),'' )          
  19. set @execsqltmp = ' select '|| @sKeyFiled ||' from #temptable' + @dt + ' where sybid>' || convert(varchar,@iStart) || ' and sybid <= ' || convert(varchar,(@iStart/@iLimit+1)*@iLimit)  
  20. set @execsqltmp = stuff(@qry,charindex('where',@qry),5,' where '|| @sKeyFiled || ' in ('|| @execsqltmp ||') and ')   
  21. end
  22. set @execsql = stuff(@execsql, charindex('from',@execsql),4,'into #temptable' + @dt + ' from')
  23. select (@execsql) as sql, @execsqltmp as sqlTmp
  24. set rowcount 0
  25. end

调用

 
 
 
  1. $sSQL = " exec SP_PHP_PAGE '$sSQL',$iStart,$iLimit,'iId'";
  2. $pRow = $this->m_hDb->GetResult ( $sSQL );
  3. $this->m_hDb->Excute ( $pRow->sql );
  4. $pData = $this->m_hDb->Select($pRow->sqlTmp);

网站题目:sybase分页存储过程的实现
本文URL:http://www.csdahua.cn/qtweb/news42/482592.html

网站建设、网络推广公司-快上网,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 快上网