DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`item_beforeUpdate` BEFORE UPDATE ON `item` FOR EACH ROW BEGIN DECLARE vNewPackingShelve INT; SET NEW.editorFk = account.myUser_getId(); IF ISNULL(NEW.packingShelve) AND NOT ISNULL(NEW.packingOut) THEN SELECT NEW.packingOut * vc.shelveVolume / vc.standardFlowerBox INTO vNewPackingShelve FROM vn.volumeConfig vc; SET NEW.packingShelve = vNewPackingShelve; END IF; IF NEW.itemPackingTypeFk = '' THEN SET NEW.itemPackingTypeFk = NULL; END IF; END$$ DELIMITER ;