Chinaunix首页 | 论坛 | 博客
  • 博客访问: 91763218
  • 博文数量: 19283
  • 博客积分: 9968
  • 博客等级: 上将
  • 技术积分: 196062
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-07 14:28
文章分类

全部博文(19283)

文章存档

2011年(1)

2009年(125)

2008年(19094)

2007年(63)

分类: Sybase

2008-04-21 13:24:31

问: 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) 
确定是否存在这样的记录,在执行相应的处理。

阅读(734) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~