各位大神,mysql 提示错误“variable or condition declaration after cursor or handler declaration”,请问这是什么意思?该怎么解决? 源代码如下: 
    ->create procedure delete_xs()
    -> begin
    ->   declare xh char(6);
    ->   declare number_xs cursor for
    ->     select 学号 from xs_kc;
    ->   declare found boolean default true;
    ->   declare continue handler for not found
    ->     set found=false;
    ->   open number_xs;
    ->   fetch number_xs into xh;
    ->   while found do
    ->     delete from xs where 学号=xh;
    ->     fetch number_xs into xh;
    ->   end while;
    ->   close number_xs;
    ->   end$$MySQLCursorboolean源代码select

解决方案 »

  1.   

    DELIMITER $$
    CREATE PROCEDURE delete_xs()
        BEGIN
          DECLARE xh CHAR(6);
          DECLARE FOUND BOOLEAN DEFAULT TRUE;
          DECLARE number_xs CURSOR FOR
            SELECT 学号 FROM xs_kc;
          
          DECLARE CONTINUE HANDLER FOR NOT FOUND
            SET FOUND=FALSE;
          OPEN number_xs;
          FETCH number_xs INTO xh;
          WHILE FOUND DO
            DELETE FROM xs WHERE 学号=xh;
            FETCH number_xs INTO xh;
          END WHILE;
          CLOSE number_xs;
          END$$
    DELIMITER ;
      

  2.   

    delimiter $$
    create procedure delete_xs()
        -> begin
        ->   declare xh char(6);
        ->   declare number_xs cursor for
        ->     select 学号 from xs_kc;
        ->   declare found boolean default true;
        ->   declare continue handler for not found
        ->     set found=false;
        ->   open number_xs;
        ->   fetch number_xs into xh;
        ->   while found do
        ->     delete from xs where 学号=xh;
        ->     fetch number_xs into xh;
        ->   end while;
        ->   close number_xs;
        ->   end$$ 
        ->   delimiter;
      

  3.   

    不是 delimiter $$ 的问题,我敲入了