DROP TRIGGER IF EXISTS vn2008.expeditionsBeforeDelete;
USE vn2008;

DELIMITER $$
$$
CREATE DEFINER=`root`@`%` TRIGGER `vn2008`.`expeditionsBeforeDelete`
BEFORE DELETE ON `expeditions` FOR EACH ROW
BEGIN
    UPDATE Tickets SET Bultos = (SELECT COUNT(counter)-1 
		FROM expeditions WHERE ticket_id = OLD.ticket_id and EsBulto)
		WHERE Id_Ticket = OLD.ticket_id;	
END$$
DELIMITER ;
