I keep having error messages and i'm not sure what i'm doing wrong. This is the class restaurant:
Restaurant (IdRestaurant, NameRest, Telephone, Address, Forks, NameCity, TypeCooking)
The objective is not allow restaurants with Forks that are not in the interval [1,5]
CREATE TRIGGER CorrecF
BEFORE INSERT ON Restaurant
FOR EACH ROW
BEGIN
IF (5 < new.Forks AND new.Forks < 1) THEN
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Forks have to be between 1-5';
END IF;
END;
Another one will be not allowing inserts of Offers that have a date less than 2 weeks from NOW().
Offer (IdOffer, Coffee, Drink, Date, Price, IdRest, Time_Zone)
CREATE TRIGGER CorrectDate BEFORE INSERT ON Offer
FOR EACH ROW IF (DATE_ADD(NOW(), INTERVAL 2 WEEK) > new.Date) THEN
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Date have to be minimum 2 weeks from now';
END IF;
END;