From d17856069d499e6586affb36a51ff0b89435d890 Mon Sep 17 00:00:00 2001 From: Klemjl Date: Thu, 18 Jun 2026 20:53:17 +0300 Subject: [PATCH 1/3] Solution --- task.sql | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/task.sql b/task.sql index 8adf22b..1574679 100644 --- a/task.sql +++ b/task.sql @@ -1,11 +1,11 @@ --- Use our database -USE ShopDB; +USE ShopDB; --- Some data should be created outside the transaction (here) +INSERT INTO Orders (CustomersID, Date) VALUES (1, '2023-01-01'); +SET @OrderID = LAST_INSERT_ID(); --- Start the transaction -START TRANSACTION; +START TRANSACTION; --- And some data should be created inside the transaction +INSERT INTO OrderItems (OrderID, ProductID, Count) VALUES (@OrderID, 1, 1); +UPDATE Products SET WarehouseAmount = WarehouseAmount - 1 WHERE ID = 1; COMMIT; \ No newline at end of file From 6c4a7488b91bf0abd9ba24ea3397e70525f4d271 Mon Sep 17 00:00:00 2001 From: Klemjl Date: Thu, 18 Jun 2026 21:18:29 +0300 Subject: [PATCH 2/3] Solution --- task.sql | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/task.sql b/task.sql index 1574679..6e0f937 100644 --- a/task.sql +++ b/task.sql @@ -1,9 +1,7 @@ USE ShopDB; - -INSERT INTO Orders (CustomersID, Date) VALUES (1, '2023-01-01'); -SET @OrderID = LAST_INSERT_ID(); - START TRANSACTION; +INSERT INTO Orders (CustomerID, Date) VALUES (1, '2023-01-01'); +SET @OrderID = LAST_INSERT_ID(); INSERT INTO OrderItems (OrderID, ProductID, Count) VALUES (@OrderID, 1, 1); From 44f66a62a2f8c1a922749bc768d48c9e28cf3803 Mon Sep 17 00:00:00 2001 From: Klemjl Date: Fri, 19 Jun 2026 13:29:28 +0300 Subject: [PATCH 3/3] Solution --- .idea/.gitignore | 5 +++++ .idea/inspectionProfiles/profiles_settings.xml | 6 ++++++ .idea/misc.xml | 7 +++++++ .idea/modules.xml | 8 ++++++++ .idea/rda_task_3_transactions.iml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ task.sql | 5 ++--- 7 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/rda_task_3_transactions.iml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..b58b603 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..1d3ce46 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..d007c13 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/rda_task_3_transactions.iml b/.idea/rda_task_3_transactions.iml new file mode 100644 index 0000000..d8b3f6c --- /dev/null +++ b/.idea/rda_task_3_transactions.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/task.sql b/task.sql index 6e0f937..2e695f3 100644 --- a/task.sql +++ b/task.sql @@ -1,9 +1,8 @@ USE ShopDB; -START TRANSACTION; + INSERT INTO Orders (CustomerID, Date) VALUES (1, '2023-01-01'); SET @OrderID = LAST_INSERT_ID(); - +START TRANSACTION; INSERT INTO OrderItems (OrderID, ProductID, Count) VALUES (@OrderID, 1, 1); - UPDATE Products SET WarehouseAmount = WarehouseAmount - 1 WHERE ID = 1; COMMIT; \ No newline at end of file