Stored procedure + cursor
Delimiter / /
Drop procedure if exists `test` / /
CREATE PROCEDURE `test` () comment 'test stored procedure'
BEGIN
Declare a varchar (255)
Declare i int (1) default 0
DECLARE cur CURSOR FOR select tname from `test`
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION, NOT FOUND
Rollback
Start transaction
OPEN cur
While i