No. | Title |
---|---|
1 | Explanation |
2 | Coding Example |
3 | Case Studies |
4 | Conclusion |
BEGIN TRANSACTION;
UPDATE accounts SET balance = balance - 1000 WHERE account_number = 'A123';
UPDATE accounts SET balance = balance + 1000 WHERE account_number = 'B456';
COMMIT;
BEGIN TRANSACTION;
-- Step 1: Update inventory levels
UPDATE Products
SET quantity = quantity - {ordered_quantity}
WHERE product_id = {product_id};
-- Step 2: Insert order details
INSERT INTO Orders (customer_id, order_date)
VALUES ({customer_id}, {current_date});
-- Step 3: Get the order ID
DECLARE @order_id INT;
SET @order_id = SCOPE_IDENTITY();
-- Step 4: Insert order items
INSERT INTO OrderItems (order_id, product_id, quantity)
VALUES (@order_id, {product_id}, {ordered_quantity});
COMMIT;