mysql 存储过程

1.问题描述:我想要从一个表中查找数据,然后取其中一些字段批量存到另一张表中,刚学习用存储过程,但是一直显示影响0行,不知道是哪里错了,请各位帮帮忙。谢谢了!
2.代码:

BEGIN
    #Routine body goes here...
    DECLARE id INT DEFAULT 0;
  DECLARE user_Id INT DEFAULT 0;
  DECLARE course_id INT DEFAULT 0;
  DECLARE playercount INT DEFAULT 0;
  DECLARE course_name VARCHAR(255);
  DECLARE play_time INT DEFAULT 0;
  DECLARE finish INT DEFAULT 0;
    DECLARE _done TINYINT(1) DEFAULT 0; 
  DECLARE mian_cur CURSOR FOR SELECT user_id,course_id,SUM(playercount) AS playercount,SUM(play_time) AS play_time,course_name FROM `edu_course_studyhistory` WHERE user_id = userId GROUP BY course_id ;
  DECLARE CONTINUE HANDLER FOR NOT FOUND SET _done = 1; 
  OPEN mian_cur;
  loop_xxx:LOOP 
        FETCH FROM mian_cur INTO user_id,course_id,playercount,play_time,course_name;
        IF _done=1 THEN  
            LEAVE loop_xxx;  
        END IF;
        INSERT INTO edu_course_history VALUES(NULL,user_id,course_id,playercount,course_name,now(),play_time,0);
  END LOOP;
END

3.错误信息

查看回复