I have 3 tables and a trigger in the Purchase table.
User (UserId | Balance)
Purchase (PurchaseId | UserId | Amount | IsConfirm)
TransactionDetail (TrxId | UserId | Balance |Amount)
When the Purchase IsConfirm is updated from False to True, I want the trigger to update Player Balance and insert new record(s) into TransactionDetail.
I have this bulk update statement:
UPDATE Purchase SET IsConfirm = true WHERE UserId=1
I know that trigger will only be fired once for a batch update. So if there are 5 rows updated, there is only 1 row inserted into the TransactionDetail table, and the balance is not updated correctly.
If there are 5 rows affected in a batch update,
by using trigger, is there any way to insert 5 updated rows into the TransactionDetail and update the user balance correctly?