[英]cursor sql problems
為什么它不會顯示多個結果? 此外,我收到此錯誤消息“將 varchar 值‘fetch_status’轉換為數據類型 int 時轉換失敗”我的代碼有什么問題?
Declare [plzwork] cursor
for
Select * from [itsthegoodtable]
Where [Methodofpayment] = 'pd'
---open cursor
Open [plzwork]
Fetch next from [plzwork]
while 'fetch_status' = 0
fetch next from [plzwork]
close [plzwork]
deallocate [plzwork]
您的while
條件正在比較一個字符串,該字符串恰好包含“fetch_status”與一個整數。 也許你的意思是:
while fetch_status = 0
您的代碼有點像 SQL Server。 在這種情況下,您想要:
while @@FETCH_STATUS = 0
我還強烈建議正確縮進您的代碼並在while
周圍使用begin
/ end
以防止意外錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.