這可能是一個愚蠢的語法錯誤,但我只是繼續閱讀我的程序,但我無法弄清楚我的錯誤在哪裏。SQL Server上的語法錯誤
消息156,級別15,狀態1,行 'FOR' 關鍵字 近41
不正確的語法。
這裏是我的代碼:
alter procedure LockReservation as
DECLARE @edition_id tinyint, @stockid tinyint;
DECLARE @creservation CURSOR FOR select edition_id from reservation where (date_fin - GETUTCDATE()) <= 12;
open creservation;
while @@fetch_status = 0
BEGIN
fetch creservation into @edition_id;
DECLARE @cstock CURSOR
FOR select id from stock where edition_id = @edition_id;
open cstock;
while @@fetch_status = 0
BEGIN
fetch cstock into @stockid;
select stock_id from location where location.stock_id = @stockid and archivage = 0
if @@rowcount = 0
BEGIN
insert into stocks_reserves(id, date_ajout, usure, suppression, edition_id)
Select id, date_ajout, usure, suppression, edition_id
from stock
where stock.id = @stockid
END
END
CLOSE cstock
DEALLOCATE cstock
END
CLOSE creservation
DEALLOCATE creservation
有人可以幫助我嗎?
什麼是在第41行? – 2011-03-30 19:25:08
這是我爲此方法聲明創意 – Dimitri 2011-03-30 19:26:03