I am currently working on a Java Swing application. The application allows users to perform various types of transactions. I created several tables in MS SQL to store user data. The following is the problem I'm currently facing.
I have a table called "UList" that contains all the user information. This particular table also contains the βBalanceβ column, which will contain the user's balance. There is another table called "Deposits" in which the deposit amount will be stored.
Tables:
Ulist
ββββββββ¦ββββββββββ
β id β balance β
β βββββββ¬ββββββββββ£
β 1 β 6000 β
β 2 β 4000 β
ββββββββ©ββββββββββ
Deposits
ββββββββ¦βββββββ
β amt β id β
β βββββββ¬βββββββ£
β 1000 β 2 β
β 1000 β 1 β
β 500 β 1 β
β 500 β 1 β
ββββββββ©βββββββ
, , amt / . , .
create trigger d_trigger
ON Deposits
AFTER INSERT
AS
UPDATE u set u.balance=u.balance+d.amt from UList u INNER JOIN deposits d on u.id=d.id INNER JOIN inserted i on i.id=d.id
, . 500, 500 , , , 1000, . , , , ..
!
. , Java, . , MS SQL Server.