21 lines
440 B
SQL
21 lines
440 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`delivery_beforeInsert`
|
|
BEFORE INSERT ON `delivery`
|
|
FOR EACH ROW
|
|
BEGIN
|
|
|
|
IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL)
|
|
THEN
|
|
UPDATE address
|
|
SET longitude = NEW.longitude,
|
|
latitude = NEW.latitude
|
|
WHERE id IN (
|
|
SELECT addressFK
|
|
FROM ticket
|
|
WHERE id = NEW.ticketFk
|
|
);
|
|
END IF;
|
|
|
|
END$$
|
|
DELIMITER ;
|