Triggers condicionais en SQL
octubre 5, 2021Exemplo dun trigger condicional que controla que non se poida poñer un prezo negativo nin desorbitado:
DELIMITER $$
CREATE TRIGGER REVISA_PRECIO_BU BEFORE UPDATE ON PRODUCTOS FOR EACH ROW
BEGIN
IF(NEW.PRECIO<0) THEN
SET NEW.PRECIO=0;
ELSE IF(NEW.PRECIO>1000) THEN
SET
NEW.PRECIO=1000;
END IF;
END;$$
DELIMITER ;
Can I just say what a comfort to find somebody who truly understands what theyre talking about on the net. You certainly understand how to bring a problem to light and make it important. A lot more people really need to look at this and understand this side of the story. I cant believe youre not more popular because you definitely possess the gift.