Multiple cursors in nested loops in MySQL

前端 未结 5 611
半阙折子戏
半阙折子戏 2021-02-05 11:14

I wish to do something which appear a bit complicated in MySQL. In fact, I wish to open a cursor, do a loop, and in this loop, open a second cursor using the data from the previ

5条回答
  •  星月不相逢
    2021-02-05 11:46

    you could use loop,and reset the value of the handle,like this:

    get_something:loop
      open cur;
      fetch cur into temp_key;
      if no_more_record=1 then
        set no_more_record=0;
        close cur;
        leave get_something;
      else
        //do your job;
      end if;
    end loop;
    

提交回复
热议问题