DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_checkPackaging`(vSelf INT) BEGIN DECLARE vDone BOOL; DECLARE vEntryFk INT; DECLARE cTravelEntries CURSOR FOR SELECT id FROM entry WHERE entry.travelFk = vSelf; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; OPEN cTravelEntries; l: LOOP SET vDone = FALSE; FETCH cTravelEntries INTO vEntryFk; IF vDone THEN LEAVE l; END IF; CALL entry_checkPackaging(vEntryFk); END LOOP; CLOSE cTravelEntries; END$$ DELIMITER ;