From 28de6864141abf7efc0d416a5f33828890c1f8b6 Mon Sep 17 00:00:00 2001 From: ten4i Date: Sat, 9 May 2026 20:53:05 +0000 Subject: [PATCH 1/3] solution by ten4i --- task.sql | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/task.sql b/task.sql index 8adf22b..cd1bc22 100644 --- a/task.sql +++ b/task.sql @@ -1,11 +1,10 @@ -- 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; +INSERT INTO OrderItems (OrderID, ProductID, Count) VALUES (1, 1, 1); +UPDATE Products SET WarehouseAmount = WarehouseAmount - 1 WHERE ID = 1; --- And some data should be created inside the transaction - -COMMIT; \ No newline at end of file +COMMIT; From 373544fcc905aeccf126cd24a2658d7dd3a5db52 Mon Sep 17 00:00:00 2001 From: ten4i Date: Sat, 9 May 2026 21:38:31 +0000 Subject: [PATCH 2/3] moved insert into transaction --- task.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/task.sql b/task.sql index cd1bc22..430d0f0 100644 --- a/task.sql +++ b/task.sql @@ -1,9 +1,9 @@ -- Use our database USE ShopDB; -INSERT INTO Orders (CustomerID, DATE) VALUES (1, '2023-01-01'); -- 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); UPDATE Products SET WarehouseAmount = WarehouseAmount - 1 WHERE ID = 1; From e612de984a983cec1d09c727a97ffc1b537de5f5 Mon Sep 17 00:00:00 2001 From: ten4i Date: Sat, 9 May 2026 21:47:29 +0000 Subject: [PATCH 3/3] returned the insertion on an old place --- task.sql | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/task.sql b/task.sql index 430d0f0..36a0888 100644 --- a/task.sql +++ b/task.sql @@ -1,10 +1,9 @@ -- Use our database USE ShopDB; +INSERT INTO Orders (CustomerID, DATE) VALUES (1, '2023-01-01'); -- 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); UPDATE Products SET WarehouseAmount = WarehouseAmount - 1 WHERE ID = 1; - COMMIT;