-
Notifications
You must be signed in to change notification settings - Fork 180
Solution #181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Solution #181
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,9 +3,13 @@ USE ShopDB; | |
|
|
||
| -- Some data should be created outside the transaction (here) | ||
|
|
||
| INSERT INTO Orders (CustomerID, Date) | ||
| VALUES (1, "2023-01-01"); | ||
|
Comment on lines
+6
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move this |
||
| -- Start the transaction | ||
| START TRANSACTION; | ||
|
|
||
| INSERT INTO OrderItems (OrderID, ProductID, Count) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hardcoded |
||
| VALUES (LAST_INSERT_ID(), 1, 1); | ||
| UPDATE Products SET WarehouseAmount = WarehouseAmount - 1 where Name = "AwersomeProduct"; | ||
| -- And some data should be created inside the transaction | ||
|
|
||
| COMMIT; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment incorrectly suggests Orders should be created outside the transaction. Based on the business rules, all three operations (Orders, OrderItems, Products update) must succeed or fail together. The
START TRANSACTIONshould come immediately afterUSE ShopDB;.