I want to create a trigger with condition, there's 2 table Trx (Columns = TrxResp, Prodcode, TrxFwdIID, TrxTType) and Deposit (Columns = AccountXID, Balance).
The case is if table Trx update with conditon where TrxResp in (51,55) and Prodcode in (101001, 103001) and TrxFwdIID = (28) and TrxTType in (30,1,49,46), then trigger will update column Balance in table Deposit with this condition:
@Amount = 2000
@Accountxid = 123
update Deposit set Balance = Balance - @Amount where AccountXID = @AccountXID;
I tried to write the script like below but I guess I'm completely wrong
CREATE TRIGGER "UpdateDepositBalance" after update OF prodcode in (101001, 103001),trxFwdIId = 28,trxttype in (30,1,49,46),trxresp in (51,55)
on TRx
for each row
begin
declate @Amount int;
declare @Accountxid int;
set @Amount = 2000
set @Accountxid = 123
update Deposit set Balance = Balance - @Amount where AccountXID = @AccountXID;
end;
Can someone help me, please. I'm so weak at triggers and SP