This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
START TRANSACTION;
|
||||
|
||||
INSERT INTO
|
||||
Orders (
|
||||
OrderID,
|
||||
ClientID,
|
||||
ProductID,
|
||||
Quantity,
|
||||
Cost,
|
||||
Date
|
||||
)
|
||||
VALUES (
|
||||
32,
|
||||
'C11',
|
||||
'P1',
|
||||
10,
|
||||
500,
|
||||
'2022-09-30'
|
||||
);
|
||||
|
||||
UPDATE Products
|
||||
SET
|
||||
NumberOfItems = (NumberOfItems - 10)
|
||||
WHERE
|
||||
ProductID = 'P1';
|
||||
|
||||
SELECT o.OrderID, o.ClientID, o.Quantity, p.ProductID, p.NumberOfItems
|
||||
FROM Orders AS o
|
||||
INNER JOIN Products AS p ON o.ProductID = p.ProductID
|
||||
WHERE
|
||||
o.OrderID = 32;
|
||||
|
||||
select * from Orders;
|
||||
|
||||
-- ROLLBACK;
|
||||
|
||||
SELECT * FROM Orders WHERE OrderID = 32;
|
||||
|
||||
SELECT * FROM Products WHERE ProductID = 'P1';
|
||||
|
||||
START TRANSACTION;
|
||||
|
||||
INSERT INTO
|
||||
Orders (
|
||||
OrderID,
|
||||
ClientID,
|
||||
ProductID,
|
||||
Quantity,
|
||||
Cost,
|
||||
Date
|
||||
)
|
||||
VALUES (
|
||||
30,
|
||||
'Cl1',
|
||||
'P1',
|
||||
10,
|
||||
500,
|
||||
'2022-09-30'
|
||||
);
|
||||
|
||||
UPDATE Products
|
||||
SET
|
||||
NumberOfItems = (NumberOfItems - 10)
|
||||
WHERE
|
||||
ProductID = 'P1';
|
||||
|
||||
SELECT o.OrderID, o.ClientID, o.Quantity, p.ProductID, p.NumberOfItems
|
||||
FROM Orders AS o
|
||||
INNER JOIN Products AS p ON o.ProductID = p.ProductID
|
||||
WHERE
|
||||
o.OrderID = 30;
|
||||
|
||||
COMMIT;
|
||||
Reference in New Issue
Block a user