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 8adf22b..2e695f3 100644 --- a/task.sql +++ b/task.sql @@ -1,11 +1,8 @@ --- Use our database -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 +USE ShopDB; +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