I want to check whether age is greater than 18 years before inserting the record to 'employees' table. I'm using phpMyAdmin gui trigger tool. But it gives following error when I type this script in Definition section.
BEGIN
IF (DATEDIFF(CURRENT_DATE(),NEW.birth_date) < 6570) THEN
RAISEERROR('Age is less than 18 years!',16,1)
ROLLBACK
END IF
END
Please help me to resolve this.
RAISEERROR
andROLLBACK
are used in TSQL (Microsoft SQL Server) syntax.In the case of MySQL, we use
SIGNAL .. SET MESSAGE_TEXT ..
to throw an exception inside the Trigger: