mysql自定义函数初始化数据:init_data()

DELIMITER $$

USE `local_hnyz`$$

DROP FUNCTION IF EXISTS `init_data`$$

CREATE DEFINER=`root`@`localhost` FUNCTION `init_data`() RETURNS INT(11)
BEGIN
DECLARE ind INT DEFAULT 1;
-- 同步扩展表信息
INSERT INTO se_marker_site_expansion (
ID,MARKER_SITE_ID,MARKER_SITE_ADDRESS,LONGITUDE,LATITUDE,BUSINESS_INFO,PROMISE_TIME,BUSINESS_STATUS
)
SELECT
REPLACE(CONCAT(UUID(),UUID()),'-',''),ms.`id`,ms.`address`,10,10,'刻章',24,'1'
FROM
lv_marker_site ms;

-- 初始化价格配置
DELETE FROM se_price_allocation WHERE CONFIG_USER_NAME LIKE 'system' AND CONFIG_USER_PHONE='18878562378';
WHILE ind < 8 DO
INSERT INTO se_price_allocation (
ID,MARKER_SITE_ID,CONFIG_USER_NAME,CONFIG_USER_PHONE,CONFIG_USER_IDENTITY_NUM,METERIAL_TYPE,METERIAL_PRICE
)
SELECT
REPLACE(CONCAT(UUID(),UUID()),'-',''),ms.`id`,'system','18878562378','43243243243234',CONCAT(ind,''),70
FROM
lv_marker_site ms;
SET ind = ind+1;
END WHILE;
RETURN 0;
END$$

DELIMITER ;

posted @ 2019-08-16 09:43  qing222  阅读(1017)  评论(0编辑  收藏  举报