您的位置:首页 >> 数据库 >> Sybase >> 正文
RSS
 

sybase存储过程问题

http://www.rdxx.com 06年03月22日 18:11 网络 我要投稿

关键词: 问题 , 存储过程 , Sybase , ASE , 存储
问: Sybase存储过程,为什么执行到这一句就不执行了 
select @nSerialNo = serialno from schedule where phonenum= @strPhoneNum and type = @nType 
if @@rowcount = 0 
begin 
... 
end 
else 
begin 
... 
end 
上面的select结果是空记录集,存储过程一执行到空记录集,就会返回?

答:if exists(select @nSerialNo = serialno from schedule where phonenum= @strPhoneNum and type = @nType)这个语句的逻辑有点问题? 
if exists 一般是用来确定是否存在类似的记录?你现在又要将存在的结果赋值?其实还不如写 if exists(select 1 from schedule where phonenum= @strPhoneNum and type = @nType) 
确定是否存在这样的记录,在执行相应的处理。

 
 
标签: 问题 , 存储过程 , Sybase , ASE , 存储 打印本文
 
 
  热点搜索
 
 
 



Valid XHTML 1.0 Transitional
Copyright ©2005 - 2008 Rdxx.Com,All Rights Reserved
收藏本页
收藏本站