From f414f19bb20381fd9ce55551451e82dc13ef74ad Mon Sep 17 00:00:00 2001 From: ProstoPonchik Date: Mon, 8 Jun 2026 23:50:26 +0200 Subject: [PATCH 1/3] Solved! --- task.sql | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/task.sql b/task.sql index 8adf22b..f1b32f7 100644 --- a/task.sql +++ b/task.sql @@ -1,11 +1,17 @@ -- Use our database USE ShopDB; --- Some data should be created outside the transaction (here) +INSERT INTO Orders (CustomerID, Date) +VALUES (1, '2023-01-01'); -- Start the transaction START TRANSACTION; --- And some data should be created inside the transaction +INSERT INTO OrderItems (OrderID, ProductID, Count) +VALUES (1, 1, 1); + +UPDATE Products +SET WarehouseAmount = WarehouseAmount - 1 +WHERE ID = 1; COMMIT; \ No newline at end of file From 5a7e63b1c16b7d1373e19d8c9bfc5b6047fd52bc Mon Sep 17 00:00:00 2001 From: ProstoPonchik Date: Tue, 9 Jun 2026 00:05:49 +0200 Subject: [PATCH 2/3] Fixed --- task.sql | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/task.sql b/task.sql index f1b32f7..abeb507 100644 --- a/task.sql +++ b/task.sql @@ -1,12 +1,15 @@ -- Use our database USE ShopDB; -INSERT INTO Orders (CustomerID, Date) -VALUES (1, '2023-01-01'); +-- ShopDB should be created by running create-database.sql before this script. +-- AwersomeProduct with ID 1 and customer with ID 1 are inserted there as initial data. --- Start the transaction +-- Start the transaction START TRANSACTION; +INSERT INTO Orders (CustomerID, Date) +VALUES (1, '2023-01-01'); + INSERT INTO OrderItems (OrderID, ProductID, Count) VALUES (1, 1, 1); @@ -14,4 +17,4 @@ UPDATE Products SET WarehouseAmount = WarehouseAmount - 1 WHERE ID = 1; -COMMIT; \ No newline at end of file +COMMIT; From 2906e8095c238273dc56c06946094f5dccc69c4a Mon Sep 17 00:00:00 2001 From: ProstoPonchik Date: Tue, 9 Jun 2026 00:08:07 +0200 Subject: [PATCH 3/3] Fixed 2.0! --- task.sql | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/task.sql b/task.sql index abeb507..bf60765 100644 --- a/task.sql +++ b/task.sql @@ -1,20 +1,19 @@ -- Use our database -USE ShopDB; +USE ShopDB; -- ShopDB should be created by running create-database.sql before this script. -- AwersomeProduct with ID 1 and customer with ID 1 are inserted there as initial data. --- Start the transaction -START TRANSACTION; - INSERT INTO Orders (CustomerID, Date) VALUES (1, '2023-01-01'); +-- Start the transaction +START TRANSACTION; + INSERT INTO OrderItems (OrderID, ProductID, Count) VALUES (1, 1, 1); -UPDATE Products -SET WarehouseAmount = WarehouseAmount - 1 +UPDATE Products SET WarehouseAmount = WarehouseAmount - 1 WHERE ID = 1; -COMMIT; +COMMIT;