6. Trigger - Exercises: Triggers and Transactions Part II - Queries for Diablo Database
Привет на всички, доста ме поизмъчи тази задача ако някой ми погне да каже къде бъркам ще съм му много благодарен!
Значи в колона Cash за съответния UserName в цифрите ми има малко разминаване. Като изключим кода ми че не е в тригер, и не ползвам процедури и view-та изчисленията нещо не са коректни!
Ето условието на задачата:
6.Trigger
Users should not to buy items with a higher level than their level. Create a trigger that restricts that. The trigger should prevent inserting items that are above the specified level while allowing all others to .
Add bonus cash of 50000 to users: baleremuda, loosenoise, inguinalself, buildingdeltoid, monoxidecos in the game "Bali".
There are two groups of items that you must buy for the above users. The first are items with id between 251 and 299 including. The second group are items with id between 501 and 539 including.
Take cash from each user for the bought items.
Select all users in the current game ("Bali") with their items. Display username, game name, cash and item name. Sort the result by username alphabetically, then by item name alphabetically.
Output
Username |
Name |
Cash |
Item Name |
baleremuda |
Bali |
41153.00 |
Iron Wolves Doctrine |
baleremuda |
Bali |
41153.00 |
Irontoe Mudsputters |
… |
… |
… |
… |
buildingdeltoid |
Bali |
38800.00 |
Alabaster Gloves |
… |
… |
… |
… |
Ето и моето решение:
https://pastebin.com/xYmZTeLn