Search code examples
mysqlloopswhile-loopcursorfetch

What's the difference between FETCH NEXT and FETCH (without NEXT) when dealing with CURSOR in MySQL?


What's the difference between FETCH NEXT and FETCH (without NEXT) when dealing with CURSOR in MySQL?

And can I use the global variable @@FETCH_STATUS to replace the following verbose sentence? --

DECLARE CONTINUE HANDLER FOR NOT FOUND SET v_done = 1;

Just as:

WHILE @@FETCH_STATUS = 0 DO
    ......
END WHILE;

It seems more elegant and simpler.


Solution

  • The answer is there's no difference between them. They are totally same.