select @nSerialNo = serialno from wxdg_schedule where phonenum= @strPhoneNum and type = @nType
--执行了上面的select语句,就无法继续往下执行(执行不了下面的IF语句)
if @@rowcount = 0
begin
if @nType = 6
begin
set rowcount 1
select @nSerialNo=a.serialno,@strVoiceFile=isnull(a.voicefile,''),@strResourceVoice=a.musicfile,@nID=a.id from wxdg_song a,wxdg_favorite b where a.id=b.id and b.phonenum=@strPhoneNum and a.musicfile is not null order by a.serialno
--收藏夹无内容
if @@RowCount = 0
begin
select '1;||;0'
set rowcount 0
return
end
set rowcount 0
end
else
begin
set rowcount 1
select @nSerialNo=serialno,@strVoiceFile=isnull(voicefile,''),@strResourceVoice=musicfile,@nID=id from wxdg_song where type=@nType and musicfile is not null order by serialno
set rowcount 0
end
insert into wxdg_schedule(phonenum,type,serialno) values(@strPhoneNum,@nType,@nSerialNo)
end
else
begin
if @nType=6
begin
set rowcount 1
select @nSerialNo=a.serialno,@strVoiceFile=isnull(a.voicefile,''),@strResourceVoice=a.musicfile,@nID=a.id from wxdg_song a,wxdg_favorite b
where a.musicfile is not null and a.serialno>;@nSerialNo and a.id=b.id and b.phonenum=@strPhoneNum order by a.serialno
if @@RowCount = 0
begin
select @nSerialNo=a.serialno,@strVoiceFile=isnull(a.voicefile,''),@strResourceVoice=a.musicfile,@nID=a.id from wxdg_song a,wxdg_favorite b
where a.id=b.id and b.phonenum=@strPhoneNum and a.musicfile is not null order by a.serialno
--收藏夹无内容
if @@RowCount = 0
begin
select '1;||;0'
set rowcount 0
return
end
end
set rowcount 0
end
else
begin
set rowcount 1
select @nSerialNo=serialno,@strVoiceFile=isnull(voicefile,''),@strResourceVoice=musicfile,@nID=id from wxdg_song where type=@nType and musicfile is not null and serialno>;@nSerialNo order by serialno
if @@rowcount = 0
begin
select @nSerialNo=serialno,@strVoiceFile=isnull(voicefile,''),@strResourceVoice=musicfile,@nID=id from wxdg_song where type=@nType and musicfile is not null order by serialno
end
set rowcount 0
end
update wxdg_schedule set serialno=@nSerialNo where phonenum=@strPhoneNum and type=@nType
end
if @nType=6
begin
select @nFavSongNum=count(1) from wxdg_favorite where phonenum=@strPhoneNum
作者: 2BeSybPro 时间: 2005-07-08 22:38 标题: sybase存储过程问题 Man, Chuxu already answered your question.
select @nSerialNo = serialno from wxdg_schedule where phonenum= @strPhoneNum and type = @nType
If the result set is null, you will get error.
So you can do either way:
1. select @nSerialNo = isnull(serialno,0) from wxdg_schedule where phonenum= @strPhoneNum and type = @nType
if @SerialNo = 0 -- don't use @@rowcount
begin
...
end
else
begin
...
end
2. Put some error handling code after this sql statement作者: jysql 时间: 2005-07-09 23:52 标题: sybase存储过程问题 你是不是不用判断@@rowcount,而直接判断@@sqlstatus呢作者: yeath 时间: 2005-07-10 02:10 标题: sybase存储过程问题 可能是我的SYBASE没安装好吧,怎么会有这种问题。作者: wyz9324 时间: 2005-07-19 17:26 标题: sybase存储过程问题 有详细的出错信息吗?