22 lines
414 B
SQL
22 lines
414 B
SQL
DROP TRIGGER IF EXISTS `vn2008`.`ArticlesBeforeInsert`;
|
|
|
|
DELIMITER $$
|
|
USE `vn2008`$$
|
|
CREATE DEFINER=`root`@`%` TRIGGER `vn2008`.`ArticlesBeforeInsert`
|
|
BEFORE INSERT ON `Articles` FOR EACH ROW
|
|
BEGIN
|
|
DECLARE vDensity DOUBLE;
|
|
DECLARE vInsertId INT;
|
|
|
|
IF NEW.density IS NULL
|
|
THEN
|
|
SELECT density INTO vDensity
|
|
FROM Tipos WHERE tipo_id = NEW.tipo_id;
|
|
|
|
SET NEW.density = vDensity;
|
|
END IF;
|
|
|
|
|
|
END$$
|
|
DELIMITER ;
|