当前位置:服务支持 >  软件文章 >  sybase分页存储过程实现 高效数据展示方案

sybase分页存储过程实现 高效数据展示方案

阅读数 6
点赞 0
article_banner

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

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

调用

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

 

 

 

免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删
相关文章
QR Code
微信扫一扫,欢迎咨询~

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 155-2731-8020
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

手机不正确

公司不为空