title: Dynamic cursor in stored procedure
body: <p>I would like to use LIMIT in a cursor. The cursor should be used and updated several times within a loop, each time with different parameters of LIMIT. Here some code:</p>
  
  <pre><code>DELIMITER $$
  CREATE PROCEDURE `updateIt`() READS SQL DATA
  BEGIN
  
  declare done int(1) default 0;
  declare counter int(10) default 0;
  declare xabc int(10) default 0;
  
  declare tab1Cursor cursor for select abc from tab1 limit 100000*counter, 100000;
  declare continue handler for not found set done=1;
  
  loopCounter: LOOP
      set done = 0;
      open tab1Cursor;
      igmLoop: loop
          fetch tab1Cursor into xabc;
          if done = 1 then leave igmLoop; end if;
          -- do something
      end loop igmLoop;
      close tab1Cursor;
  
      if (counter = 1039) 
          leave loopCounter;
      end if;
      set counter = counter + 1;
  
  END LOOP loopCounter;
  END $$
  DELIMITER ;
  </code></pre>
  
  <p>This, however, does not work (I also tried it with the cursor in the LOOP counterLoop). Can Mysql deal with dynamic cursors?</p>