2
我的存儲過程SAP B1有問題。while循環SAP B1 SQL存儲過程阻塞
我在這裏要做的是存儲數量的總和,按製造訂單分組,並將其插入臨時表中。然後使用while循環遍歷每個ID以與用戶表格[@FGTRACKING]進行比較,並在[[FGTracking]中設置 temp.quantity> sum(quantity)]。
但是這不起作用,事務仍然通過存儲過程塊。我懷疑我的語法有問題。
IF @transaction_type IN ('A') AND @object_type = '67'
BEGIN
declare @top as int
declare @temp table (id int,quantity int NOT NULL, monum int NOT NULL)
insert into @temp (id, quantity,monum)
select row_number() over (order by (select NULL)), sum(quantity) as quantity, u_shipment_line as monum
from wtr1 t1
where t1.docentry = @list_of_cols_val_tab_del
group by u_shipment_line
set @top = 1
WHILE @top <= (select count(monum) from @temp)
BEGIN
IF EXISTS (select t100.monum from @temp t100
where t100.quantity > (select sum(t111.u_transfer)
from [@FGTRACKING] t111 where t111.u_mo_num = t100.monum
group by t111.u_mo_num) and t100.id = @top)
BEGIN
SELECT @Error = 666, @error_message = 'Over-transfer'
END
ELSE
set @top = @top + 1
END
END
編輯您的問題並使用正確的縮進。你會立即看到你的錯誤是什麼。 – FDavidov