I intend to write a SQL transaction to insert an order if a product has enough inventory (make sure no two customers both success to buy a product with only 1 inventory at the same time), like this:
START TRANSACTION;
UPDATE products SET inventory=inventory-1 WHERE product_id=1 AND inventory>=1;
if (update succeeded) INSERT order ...;
COMMIT;
How can I check whether the products' inventory update succeeded. Do I have to use the procedure?