salix/db/routines/vn/triggers/itemShelvingSale_afterInser...

12 lines
410 B
SQL

DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemShelvingSale_afterInsert`
AFTER INSERT ON `itemShelvingSale`
FOR EACH ROW
BEGIN
UPDATE sale s
JOIN operator o ON o.workerFk = account.myUser_getId()
JOIN sector se ON se.id = o.sectorFk
SET s.isPicked = IF(IFNULL(se.isOnReservationMode, o.isOnReservationMode), s.isPicked, TRUE)
WHERE s.id = NEW.saleFk;
END$$
DELIMITER ;