salix/db/routines/vn/triggers/sharingCart_beforeInsert.sql

16 lines
500 B
MySQL
Raw Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`sharingCart_beforeInsert`
BEFORE INSERT ON `sharingCart`
FOR EACH ROW
BEGIN
IF NEW.workerFk = NEW.workerSubstitute THEN
CALL util.throw ('worker and workerSubstitute must be different');
ELSE
INSERT IGNORE INTO sharingCartDaily (ownerFk, substituteFk, dated)
SELECT NEW.workerFk, NEW.workerSubstitute, dated
FROM time
WHERE dated BETWEEN NEW.started AND NEW.ended;
END IF;
END$$
DELIMITER ;