DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerTimeControlSOWP`(IN vUserFk INT, IN vDated DATE) BEGIN SET @order := 0; UPDATE workerTimeControl SET `order` = @order := @order + 1 WHERE vUserFk =userFk AND vDated = DATE(timed) ORDER BY timed; END$$ DELIMITER ;