16 lines
449 B
MySQL
16 lines
449 B
MySQL
|
DELIMITER $$
|
||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerTimeControl_setOrder`(vUserFk INT, vStarted DATE, vFinished DATE)
|
||
|
BEGIN
|
||
|
|
||
|
SET @order := 0;
|
||
|
SET @day := '2000-01-01';
|
||
|
|
||
|
UPDATE vn.workerTimeControl w
|
||
|
SET w.`order` = @order := IF(@day = @day := date(timed), @order, 0) + 1
|
||
|
WHERE w.userFk = vUserFk
|
||
|
AND w.timed BETWEEN vStarted AND util.dayend(vFinished)
|
||
|
ORDER BY w.timed;
|
||
|
|
||
|
END$$
|
||
|
DELIMITER ;
|