免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 3837 | 回复: 16
打印 上一主题 下一主题

sybase存储过程问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-07-05 23:06 |只看该作者 |倒序浏览
SYBASE存储过程,为什么执行到这一句就不执行了
select @nSerialNo = serialno from schedule where phonenum= @strPhoneNum and type = @nType
if @@rowcount = 0
begin
...
end
else
begin
...
end
上面的select结果是空记录集,存储过程一执行到空记录集,就会返回?

论坛徽章:
0
2 [报告]
发表于 2005-07-06 00:50 |只看该作者

sybase存储过程问题

update ur sp and try to use:
if exists (select ....)
begin
..
end
else
begin
..
end

论坛徽章:
0
3 [报告]
发表于 2005-07-06 08:48 |只看该作者

sybase存储过程问题

if exists(select @nSerialNo = serialno from schedule where phonenum= @strPhoneNum and type = @nType)这样的语句是错误的,执行不了。我想问一下为什么上面的写法不行?

论坛徽章:
0
4 [报告]
发表于 2005-07-06 13:24 |只看该作者

sybase存储过程问题

没人知道这是什么原因,高手别沉默啊

论坛徽章:
1
2017金鸡报晓
日期:2017-01-10 15:19:56
5 [报告]
发表于 2005-07-06 14:30 |只看该作者

sybase存储过程问题

满足这个phonenum= @strPhoneNum and type = @nType条件的是不是不止一条呀?

论坛徽章:
0
6 [报告]
发表于 2005-07-06 18:55 |只看该作者

sybase存储过程问题

满足这个phonenum= @strPhoneNum and type = @nType条件的记录为空(没有满足这个条件的记录)

论坛徽章:
1
2017金鸡报晓
日期:2017-01-10 15:19:56
7 [报告]
发表于 2005-07-06 20:10 |只看该作者

sybase存储过程问题

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

论坛徽章:
0
8 [报告]
发表于 2005-07-06 23:12 |只看该作者

sybase存储过程问题

有没有类似on exception resume这样的语句?就是执行到了空记录,还是继续往下执行。

论坛徽章:
1
2017金鸡报晓
日期:2017-01-10 15:19:56
9 [报告]
发表于 2005-07-07 07:57 |只看该作者

sybase存储过程问题

可以用isnull(serialno,0)的语法,在没记录时赋一个固定的值。

论坛徽章:
0
10 [报告]
发表于 2005-07-07 12:25 |只看该作者

sybase存储过程问题

现在是一执行到空记录的select,整个存储过程就返回了,根本不往下面走。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP