19 lines
551 B
SQL
19 lines
551 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn2008`.`agency_hour_afterUpdate`
|
|
AFTER UPDATE ON `agency_hour`
|
|
FOR EACH ROW
|
|
BEGIN
|
|
DECLARE vAlreadyExists BOOLEAN DEFAULT FALSE;
|
|
|
|
SELECT COUNT(*) INTO vAlreadyExists
|
|
FROM vn2008.agency_hour
|
|
WHERE NEW.week_day <=> week_day AND NEW.province_id <=> province_id
|
|
AND NEW.warehouse_id <=> warehouse_id AND NEW.max_hour <=> max_hour
|
|
AND NEW.agency_id <=> agency_id;
|
|
|
|
IF vAlreadyExists > 1 THEN
|
|
CALL util.throw('ALREADY_EXISTS');
|
|
END IF;
|
|
END$$
|
|
DELIMITER ;
|