In MariaDB and MySQL, Cursors can only be used within a Stored Program, are slow, and have very limited functionalities. That said, they can still be useful in some cases. This page explains how to use them in action, with a trivial example.
Here is our example Stored Procedure which uses a Cursor:
DELIMITER || DROP TABLE IF EXISTS `test`.`tab1`; CREATE TABLE `test`.`tab1` (`c` TINYINT UNSIGNED); INSERT INTO `test`.`tab1` (`c`) VALUES (1), (2), (3); …