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

22 lines
525 B
MySQL
Raw Normal View History

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);
-- Actualizar agencyFk y agencyModeFk
IF NEW.agencyFk THEN
SET NEW.agencyModeFk = NEW.agencyFk;
END IF;
IF NEW.agencyModeFk THEN
SET NEW.agencyFk = NEW.agencyModeFk;
END IF;
CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);
END$$
DELIMITER ;