DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`indicatorsUpdateLauncher`() BEGIN DECLARE vDated DATE; SELECT IFNULL(TIMESTAMPADD(DAY,1,MAX(updated)), '2018-04-01') INTO vDated FROM bs.indicators; WHILE vDated < util.VN_CURDATE() DO CALL indicatorsUpdate(vDated); SELECT TIMESTAMPADD(DAY,1,MAX(updated)) INTO vDated FROM bs.indicators; END WHILE; END$$ DELIMITER ;