From 0bc60ee6e01846bfd04ceb86cc5dce72d5fa871c Mon Sep 17 00:00:00 2001 From: Ivan Date: Wed, 11 Mar 2026 17:13:33 +0100 Subject: [PATCH 1/3] trx is created --- task.sql | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/task.sql b/task.sql index 8adf22b..1994497 100644 --- a/task.sql +++ b/task.sql @@ -2,10 +2,12 @@ USE ShopDB; -- Some data should be created outside the transaction (here) - --- Start the transaction -START TRANSACTION; - --- And some data should be created inside the transaction - +INSERT INTO Order(CustomerID, Date) VALUE (1, "2023-01-01"); +-- Start the transaction +START TRANSACTION; + +-- And some data should be created inside the transaction +INSERT INTO OrderItems(OrderID, ProductID, Count) VALUE (1, 1, 0); +UPDATE Products SET WarehouseAmount = WarehouseAmount - 1 WHERE ID = 1 and Name = 'AwersomeProduct'; +UPDATE OrderItems SET Count = Count + 1 WHERE OrderID = 1 and ProductID = 1; COMMIT; \ No newline at end of file From 4442e63df4bf502b03d14b5a2063e89912426b4b Mon Sep 17 00:00:00 2001 From: Ivan Date: Wed, 11 Mar 2026 17:21:27 +0100 Subject: [PATCH 2/3] fix comments --- task.sql | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/task.sql b/task.sql index 1994497..53d89e6 100644 --- a/task.sql +++ b/task.sql @@ -2,12 +2,11 @@ USE ShopDB; -- Some data should be created outside the transaction (here) -INSERT INTO Order(CustomerID, Date) VALUE (1, "2023-01-01"); + -- Start the transaction START TRANSACTION; - -- And some data should be created inside the transaction -INSERT INTO OrderItems(OrderID, ProductID, Count) VALUE (1, 1, 0); +INSERT INTO Order(CustomerID, Date) VALUE (1, '2023-01-01'); +INSERT INTO OrderItems(OrderID, ProductID, Count) VALUE (1, 1, 1); UPDATE Products SET WarehouseAmount = WarehouseAmount - 1 WHERE ID = 1 and Name = 'AwersomeProduct'; -UPDATE OrderItems SET Count = Count + 1 WHERE OrderID = 1 and ProductID = 1; -COMMIT; \ No newline at end of file +COMMIT; \ No newline at end of file From 552d276d12f0538e50e52f18a418bdfba50c0252 Mon Sep 17 00:00:00 2001 From: Ivan Date: Wed, 11 Mar 2026 17:24:17 +0100 Subject: [PATCH 3/3] fix comments2 --- task.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/task.sql b/task.sql index 53d89e6..2aa530a 100644 --- a/task.sql +++ b/task.sql @@ -6,7 +6,7 @@ USE ShopDB; -- Start the transaction START TRANSACTION; -- And some data should be created inside the transaction -INSERT INTO Order(CustomerID, Date) VALUE (1, '2023-01-01'); +INSERT INTO Orders(CustomerID, Date) VALUE (1, '2023-01-01'); INSERT INTO OrderItems(OrderID, ProductID, Count) VALUE (1, 1, 1); UPDATE Products SET WarehouseAmount = WarehouseAmount - 1 WHERE ID = 1 and Name = 'AwersomeProduct'; COMMIT; \ No newline at end of file