mysql自定义函数多表更新:update_order_relation()

DELIMITER $$

USE `local_hnyz`$$

DROP FUNCTION IF EXISTS `update_order_relation`$$

CREATE DEFINER=`root`@`localhost` FUNCTION `update_order_relation`(orderId VARCHAR(64)) RETURNS VARCHAR(64) CHARSET utf8
BEGIN
DECLARE new_orderId VARCHAR(64);
SET new_orderId = REPLACE(UUID(),'-','');
UPDATE se_seal_order SET ID=new_orderId WHERE ID=orderId;
UPDATE se_seal_order_seal SET SEAL_ORDER_ID=new_orderId WHERE SEAL_ORDER_ID=orderId;
UPDATE se_seal_order_attachment SET seal_order_id=new_orderId WHERE seal_order_id=orderId;
RETURN new_orderId;
END$$

DELIMITER ;

转载于:https://www.cnblogs.com/sung1024/p/11362018.html

你可能感兴趣的:(mysql自定义函数多表更新:update_order_relation())