update ArticlesUpdateTrigger

This commit is contained in:
Bernat 2018-05-21 14:38:38 +02:00
parent 7566da8421
commit edc3db3f02
2 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,26 @@
DROP TRIGGER IF EXISTS `vn2008`.`Articles_AFTER_INSERT`;
DELIMITER $$
USE `vn2008`$$
CREATE DEFINER=`root`@`%` TRIGGER `vn2008`.`Articles_AFTER_INSERT` AFTER INSERT ON `Articles` FOR EACH ROW
BEGIN
CALL itemTagArrangedUpdate(NEW.Id_Article);
INSERT INTO vn.itemTaxCountry(itemFk, countryFk, taxClassFk)
SELECT NEW.Id_Article, 1, NEW.iva_group_id;
INSERT INTO vn.itemTaxCountry(itemFk, countryFk, taxClassFk)
SELECT NEW.Id_Article, 5, NEW.iva_group_id;
INSERT INTO vn.itemTaxCountry(itemFk, countryFk, taxClassFk)
SELECT NEW.Id_Article, 30, NEW.iva_group_id;
IF NEW.tipo_id IS NOT NULL THEN
INSERT INTO vn.itemTag (itemFk, tagFk, priority)
SELECT NEW.Id_Article, tagFk, priority FROM vn.itemTypeTag
WHERE itemTypeFk = NEW.tipo_id;
END IF;
END$$
DELIMITER ;