salix/db/routines/vn/triggers/travel_beforeInsert.sql

17 lines
487 B
SQL

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`travel_beforeInsert`
BEFORE INSERT ON `travel`
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
CALL travel_checkDates(NEW.shipped, NEW.landed);
CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);
IF NEW.awbFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.id) THEN
CALL util.throw('The AWB is incorrect, there is a different AWB in the associated entries');
END IF;
END$$
DELIMITER ;