一、
看一个基本的循环使用方法,oschina上用的
CREATE PROCEDURE import_invite_emails()
BBEGIN
DECLARE done INT DEFAULT 0;
DECLARE the_email VARCHAR(40);
DECLARE cur_emails CURSOR FOR SELECT DISTINCT email FROM osc_invites UNION SELECT DISTINCT email FROM osc_project_recomms;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
OPEN cur_emails;
REPEAT
FETCH cur_emails INTO the_email;
IF NOT done THEN
SELECT COUNT(*) INTO @ec FROM misc_emails WHERE email=the_email;
IF @ec = 0 THEN
SELECT COUNT(*) INTO @ec FROM osc_users WHERE email=the_email;
IF @ec = 0 THEN
INSERT INTO misc_emails (email) VALUES(the_email);
END IF;
END IF;
END IF;
UNTIL done END REPEAT;
CLOSE cur_emails;二、这是MySQL 5.5版中的一个bug,已经在5.6.3版中修正,在官网中可以查到,bug编号63864。
解决办法:
升级就可以解决这个问题,如果您不想升级那就只能先卸载掉MySQL然后删除 C:\Documents and Settings\All Users\Application Data (这个目录是隐藏的)然后再重新安装MySQL。
取消
评论