-1
    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 错误,有人可以帮我找到错误吗

4

1 回答 1

0

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

于 2013-08-09T06:46:54.550 回答