讨论数量:
DELIMITER //
CREATE PROCEDURE ProcessOrder
(IN order_id
VARCHAR (255))
BEGIN
-- 开始事务
START TRANSACTION;
-- 删除旧数据
DELETE FROM orders WHERE order_id = order_id;
-- 插入新数据
INSERT INTO orders (order_id, data) VALUES (order_id, 'new data');
-- 提交事务
COMMIT;
END //
DELIMITER ;
推荐文章: