DELIMITER $$
CREATE TRIGGER exh_locs_check
BEFORE INSERT on exhibits
FOR EACH ROW
BEGIN
DECLARE @exhibit_placements int;
SET @exhibit_placements = (SELECT COUNT(*) FROM exhibits
JOIN collections_locations
ON exhibits.id_коллекции = collections_locations.id_коллекции
WHERE exhibits.id = new.id
GROUP BY exhibits.id);
IF (@exhibit_placements) = 0 THEN
SIGNAL SQLSTATE '12345' SET MESSAGE_TEXT='Error';
END IF;
END$$
DELIMITER ;
Написано
Войдите на сайт
Чтобы задать вопрос и получить на него квалифицированный ответ.