recharge
테이블에 트리거가 생성되었습니다. onaccountregistry
테이블의 잔액을 업데이트합니다.가끔 SQL Server 트리거가 실행되지 않습니다.
가끔 내 recharge
테이블에 행을 삽입 할 때 트리거가 실행되지 않습니다. 그런 다음 값이 일치하지 않습니다. 이 recharge
테이블은 매번 행을 삽입합니다.
다음과 같이 트리거를 생성했습니다. 이것은 복제 된 테이블이 아닙니다. SQL Server 2008 Enterprise Edition을 사용하고 있습니다.
날이 문제
CREATE TRIGGER [dbo].[RechargeRefund]
ON [dbo].[ISRecharge]
FOR INSERT
AS
declare @tin char(9)
declare @depocd char(1)
declare @oldvalue money
declare @newvalue money
begin
select @tin = inserted.tin_subtin from inserted
select @depocd = inserted.updatetype from inserted
select @newvalue = inserted.DepositAmt from inserted
select @oldvalue = Totdeposit from ISOnAcctRegistry where tin_subtin = @tin
end
if @depocd ='1'
begin
update ISOnAcctRegistry
set Totdeposit = @oldvalue + @newvalue
where tin_subtin = @tin
end
if @depocd ='2'
begin
update ISOnAcctRegistry
set Totdeposit = @oldvalue - @newvalue
where tin_subtin = @tin
end
GO
삽입 된 여러 행을 어떻게 처리 할 수 있습니까? triger dear.please를 변경하면 도움이됩니다. – user1811342
@ user1811342 - 어제 제공되는 답변을 보길 원한다면 트리거를 작성하는 방법을 보여줍니다. –