Home > database >  O great god have a look at what's the problem with the trigger
O great god have a look at what's the problem with the trigger

Time:11-18


Do school library system,
Book table: table has price price char (10).
Borrow table: table has loss char (2), l_money money
Do a trigger, when the loss is "yes", then l_money price into the price of five times

CodePudding user response:

You this trigger, if incoming data loss 'is', you will be changed Borrow all the data in the table,,,
Add a primary key, at least to ensure only change a change,

CodePudding user response:

There is @ price no assignment ~ ~ ~

CodePudding user response:

How to add a primary key:
And if @ p_rice assignment, @ p_rice=price shows that price column name is invalid

CodePudding user response:

 

Declare @ l_oss char (2), @ 1 money money, @ p_rice char (10)
Select @ l_oss=loss, @ 1 money=1 _money, @ p_rice=price from inserted where isnull (loss, 'no')='is'
If ISNULL (@ l_oss, 'no')='is'
The begin
The set @ 1 money=@ 1 money + @ 1 money * (5 * @ p_rice)
Update Borrow set Borrow. 1 _money=@ 1 money from Borrow, inserted where Borrow. The name=inserted. The name
End

CodePudding user response:

Add the title is the same book...
  • Related