diff --git a/task.sql b/task.sql index 8adf22b..540117a 100644 --- a/task.sql +++ b/task.sql @@ -1,11 +1,20 @@ --- Use our database USE ShopDB; --- Some data should be created outside the transaction (here) --- Start the transaction -START TRANSACTION; +INSERT INTO Orders (CustomerID, Date) + VALUES (1, '2023-01-01'); --- And some data should be created inside the transaction + +START TRANSACTION; + +SET @order_id = LAST_INSERT_ID(); +SET @item_count = 1; + +INSERT INTO OrderItems (OrderID, ProductID, Count) + VALUES (@order_id, 1, @item_count); + +UPDATE Products +SET WarehouseAmount = WarehouseAmount - @item_count +WHERE ID = 1; COMMIT; \ No newline at end of file