From d3541247baad8ac3b207bda51106c26a5e52496c Mon Sep 17 00:00:00 2001 From: Nikita Ivanichenko Date: Wed, 3 Jun 2026 13:21:48 +0300 Subject: [PATCH 1/3] Solution --- task.sql | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/task.sql b/task.sql index 8adf22b..700067b 100644 --- a/task.sql +++ b/task.sql @@ -1,11 +1,16 @@ -- Use our database -USE ShopDB; +USE ShopDB; -- Some data should be created outside the transaction (here) +INSERT INTO Orders (ID, CustomerID, Date) +VALUES ('1', '1', '2023-01-01'); +INSERT INTO OrderItems (ID, OrderID, ProductID, Count) +VALUES ('1', '1', '1', '1'); -- Start the transaction START TRANSACTION; -- And some data should be created inside the transaction +UPDATE Products SET WarehouseAmount = WarehouseAmount - 1 WHERE ID = '1'; COMMIT; \ No newline at end of file From 512de408f81d01cb69f5f3ea51effbfa81a157bd Mon Sep 17 00:00:00 2001 From: Nikita Ivanichenko Date: Wed, 3 Jun 2026 13:28:41 +0300 Subject: [PATCH 2/3] Solution --- task.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/task.sql b/task.sql index 700067b..9c978ff 100644 --- a/task.sql +++ b/task.sql @@ -2,15 +2,15 @@ USE ShopDB; -- Some data should be created outside the transaction (here) -INSERT INTO Orders (ID, CustomerID, Date) -VALUES ('1', '1', '2023-01-01'); -INSERT INTO OrderItems (ID, OrderID, ProductID, Count) -VALUES ('1', '1', '1', '1'); -- Start the transaction START TRANSACTION; --- And some data should be created inside the transaction +-- And some data should be created inside the transaction +INSERT INTO Orders (ID, CustomerID, Date) +VALUES ('1', '1', '2023-01-01'); +INSERT INTO OrderItems (ID, OrderID, ProductID, Count) +VALUES ('1', '1', '1', '1'); UPDATE Products SET WarehouseAmount = WarehouseAmount - 1 WHERE ID = '1'; COMMIT; \ No newline at end of file From c2c89834e6252e670562c574a504b40a4f39fc59 Mon Sep 17 00:00:00 2001 From: Nikita Ivanichenko Date: Wed, 3 Jun 2026 13:32:00 +0300 Subject: [PATCH 3/3] fix --- task.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/task.sql b/task.sql index 9c978ff..faff6c8 100644 --- a/task.sql +++ b/task.sql @@ -2,13 +2,13 @@ USE ShopDB; -- Some data should be created outside the transaction (here) +INSERT INTO Orders (ID, CustomerID, Date) +VALUES ('1', '1', '2023-01-01'); -- Start the transaction START TRANSACTION; -- And some data should be created inside the transaction -INSERT INTO Orders (ID, CustomerID, Date) -VALUES ('1', '1', '2023-01-01'); INSERT INTO OrderItems (ID, OrderID, ProductID, Count) VALUES ('1', '1', '1', '1'); UPDATE Products SET WarehouseAmount = WarehouseAmount - 1 WHERE ID = '1';