sybase預存程序問題

來源:互聯網
上載者:User

問: 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 existsselect 1 from schedule where phonenum= @strPhoneNum and type = @nType)
確定是否存在這樣的記錄,在執行相應的處理。


相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.