DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `edi`.`supplyResponse_afterUpdate` AFTER UPDATE ON `supplyResponse` FOR EACH ROW BEGIN UPDATE vn.buy b JOIN vn.entry e ON e.id = b.entryFk JOIN vn.travel tr ON tr.id = e.travelFk JOIN vn.agencyMode am ON am.id = tr.agencyModeFk JOIN vn.item i ON i.id = b.itemFk JOIN edi.supplyResponse sr ON i.supplyResponseFk = sr.ID SET b.quantity = NEW.NumberOfItemsPerCask * NEW.NumberOfUnits, b.stickers = NEW.NumberOfUnits WHERE i.supplyResponseFk = NEW.ID AND am.name = 'LOGIFLORA' AND tr.isRaid AND tr.landed >= util.VN_CURDATE(); END$$ DELIMITER ;