mysql 存储过程
程序员文章站
2022-03-28 21:29:40
DELIMITER $$CREATE PROCEDURE build_school_list ()BEGIN DECLARE v_finished INTEGER DEFAULT 0; DECLARE v_shcool varchar(100) DEFAULT "";DECLARE v_shengfen varchar(100) DEFAULT "";DECLARE v_shi varchar(100) DEFAULT ""; -- declare ......
DELIMITER $$
CREATE PROCEDURE build_school_list ()
BEGIN
DECLARE v_finished INTEGER DEFAULT 0;
DECLARE v_shcool varchar(100) DEFAULT "";
DECLARE v_shengfen varchar(100) DEFAULT "";
DECLARE v_shi varchar(100) DEFAULT "";
-- declare cursor for employee email
DEClARE school_cursor CURSOR FOR
SELECT 校区,省份,市 FROM school;
-- declare NOT FOUND handler
DECLARE CONTINUE HANDLER
FOR NOT FOUND SET v_finished = 1;
OPEN school_cursor;
get_school: LOOP
FETCH school_cursor INTO v_shcool,v_shengfen,v_shi;
IF v_finished = 1 THEN
LEAVE get_school;
END IF;
update ec_data set 省份 = v_shengfen, 市 = v_shi where 所在校区 = v_shcool;
-- build email list
-- SET email_list = CONCAT(v_email,";",email_list);
END LOOP get_school;
CLOSE school_cursor;
END$$
本文地址:https://blog.csdn.net/yemenlinweihan/article/details/107408477