0
刪除多行我有兩個表,表中的一個bcdet具有交易細節和表中的兩個accmast擁有所有分類賬戶的期末餘額。當我試圖刪除任何事務時,更新不起作用。如何刪除觸發器後處理時,從表中
這裏是我的觸發代碼。
ALTER trigger [dbo].[tr_ledgerdelete]
on [dbo].[BCDet]
after delete
as
begin
declare @dlcode int;
declare @ddc nvarchar(2);
declare @dAmt float;
SET NOCOUNT ON;
set @ddc=(select dc from deleted)
set @damt=(select amt from deleted)
if (@ddc='C')
begin
update accmast set [email protected] where Lcode in (select Lcode from deleted)
update accmast set clbal=totcr-totdr+opbal where Lcode in (select Lcode from deleted)
end
else
begin
update accmast set [email protected] where Lcode in (select Lcode from deleted)
update accmast set clbal=totcr-totdr+opbal where Lcode in (select Lcode from deleted)
end
end
'update does not effect' elaborate? – SparKot
在更新accmast表中的所有clbal字段時更新的數量相同@ damt和@ddc varible根本沒有更改,它保存刪除表中的第一個值,並基於該值每個Clbal字段在accmast表中更新。 –