mysql-存储过程--demo

…衆ロ難τιáo~ 提交于 2019-12-03 02:15:55

BEGIN

DECLARE done INT DEFAULT 0 ;
DECLARE examId VARCHAR (40) ;
DECLARE cur CURSOR FOR SELECT f_id FROM `exam`.t_exam;
DECLARE CONTINUE HANDLER FOR NOT found SET done = 1 ;

DELETE FROM `report`.`t_exam_pass_member` WHERE f_id LIKE 'bigdata%';


OPEN cur ;
loop_xxx : LOOP
FETCH cur INTO examId ;
IF done = 1 THEN
LEAVE loop_xxx ;
END IF ;
INSERT INTO `report`.`t_exam_pass_member` (`f_id`, `f_exam_id`, `f_pass_member`, `f_company_id`, `f_create_time`, `f_version`)
SELECT concat('bigdata',examId), examId, '3', '1', UNIX_TIMESTAMP() * 1000, 1 ;
COMMIT;
END LOOP;
CLOSE cur ;
END

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!