2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`expedition_beforeUpdate`
|
2024-01-15 11:31:03 +00:00
|
|
|
BEFORE UPDATE ON `expedition`
|
|
|
|
FOR EACH ROW
|
|
|
|
BEGIN
|
|
|
|
SET NEW.editorFk = account.myUser_getId();
|
|
|
|
|
|
|
|
IF NEW.counter <> OLD.counter THEN
|
|
|
|
IF (SELECT COUNT(*) FROM expedition e
|
|
|
|
INNER JOIN ticket t1 ON e.ticketFk = t1.id
|
|
|
|
INNER JOIN ticket t2 ON t2.addressFk = t1.addressFk AND DATE(t2.shipped) = DATE(t1.shipped)
|
|
|
|
WHERE t1.id = NEW.ticketFk AND counter = NEW.counter) > 0 THEN
|
|
|
|
SET NEW.id = NULL;
|
|
|
|
END IF;
|
|
|
|
END IF;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|