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

19 lines
431 B
MySQL
Raw Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`item_beforeInsert`
BEFORE INSERT ON `item`
FOR EACH ROW
BEGIN
DECLARE vItemPackingType VARCHAR(1);
SET NEW.editorFk = account.myUser_getId();
IF NEW.itemPackingTypeFk IS NULL THEN
SELECT itemPackingTypeFk INTO vItemPackingType
FROM vn.itemType it
WHERE id = NEW.typeFk;
SET NEW.itemPackingTypeFk = vItemPackingType;
END IF;
END$$
DELIMITER ;