Multiple cursors in nested loops in MySQL

前端 未结 5 555
半阙折子戏
半阙折子戏 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:39

    Or redefine the CONTINUE HANDLE:

    //...
    LOOP1: LOOP
          fetch cursor1
          into  v_col1;
          if no_more_rows1 then
             close cursor1;
             leave LOOP1;
          end if;
    //...
    
          SET no_more_rows1=false;//That's new
    END LOOP LOOP1;          
    

    It seems that all select statements inside a loop execute the CONTINUE HANDLE

提交回复
热议问题