CREATE PROCEDURE getTotal()
DECLARE sname VARCHAR(10);
DECLARE done INT DEFAULT false;
DECLARE cur CURSOR FOR SELECT id,name,age from cursor_table where age>30;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = true;
FETCH cur INTO sid, sname, sage;
FETCH cur INTO sid, sname, sage;
SELECT total;END $DELIMITER ;