mysql程序错误

时间:2013-01-23 12:48:15

标签: mysql procedure

    DELIMITER $$
    CREATE PROCEDURE curdemo()

     BEGIN

    DECLARE done INT DEFAULT FALSE;
    DECLARE b, c INT;
    DECLARE cur1 CURSOR FOR SELECT empid FROM test.mytable;
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
   OPEN cur1;

   read_loop: LOOP
   FETCH cur1 INTO b;
   IF done THEN
       LEAVE read_loop;
    END IF;
    INSERT INTO test.test_log VALUES (b,'test');
    CLOSE cur1;
  END $$

编译此代码时,我得到1064错误可以帮助我找到错误

1 个答案:

答案 0 :(得分:0)

我认为这会对你有所帮助。把END LOOP;在关闭cur1之前;