From d11a26e08ebea1cb72151f29fc7b4709745824f5 Mon Sep 17 00:00:00 2001 From: Dima-shima Date: Sun, 14 Jun 2026 09:08:39 +0200 Subject: [PATCH 1/3] Edit task.sql --- task.sql | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/task.sql b/task.sql index 8adf22b..8b061db 100644 --- a/task.sql +++ b/task.sql @@ -1,11 +1,14 @@ -- Use our database USE ShopDB; --- Some data should be created outside the transaction (here) +INSERT INTO Orders (CustomerID, Date) VALUES (1, '2026-06-14'); +INSERT INTO OrderItems (OrderID, ProductID, Count) +VALUES (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 571cdf85779c837d7ffb8776259a31d75cdc614e Mon Sep 17 00:00:00 2001 From: Dima-shima Date: Sun, 14 Jun 2026 09:35:25 +0200 Subject: [PATCH 2/3] Edit task.sql --- task.sql | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/task.sql b/task.sql index 8b061db..eb1b8ce 100644 --- a/task.sql +++ b/task.sql @@ -1,14 +1,16 @@ -- Use our database USE ShopDB; -INSERT INTO Orders (CustomerID, Date) VALUES (1, '2026-06-14'); -INSERT INTO OrderItems (OrderID, ProductID, Count) -VALUES (1, 1, 1); -- Start the transaction START TRANSACTION; -UPDATE Products SET WarehouseAmount = WarehouseAmount - 1 -WHERE ID = '1'; +INSERT INTO Orders (CustomerID, Date) VALUES (1, '2026-06-14'); +SET @order_id = LAST_INSERT_ID(); +INSERT INTO OrderItems (OrderID, ProductID, Count) +VALUES (@order_id, 1, 1); +SET @qty = 1; +UPDATE Products SET WarehouseAmount = WarehouseAmount - @qty +WHERE ID = 1; COMMIT; \ No newline at end of file From 8096f4507e5c81952181e4accc7db05d9a89c84d Mon Sep 17 00:00:00 2001 From: Dima-shima Date: Sun, 14 Jun 2026 10:14:21 +0200 Subject: [PATCH 3/3] Edit task.sql --- task.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/task.sql b/task.sql index eb1b8ce..7870d7f 100644 --- a/task.sql +++ b/task.sql @@ -1,12 +1,12 @@ -- Use our database USE ShopDB; +INSERT INTO Orders (CustomerID, Date) VALUES (1, '2023-01-01'); +SET @order_id = LAST_INSERT_ID(); -- Start the transaction START TRANSACTION; -INSERT INTO Orders (CustomerID, Date) VALUES (1, '2026-06-14'); -SET @order_id = LAST_INSERT_ID(); INSERT INTO OrderItems (OrderID, ProductID, Count) VALUES (@order_id, 1, 1); SET @qty = 1;