I am dealing with triggers in MySQL, and I want to add the raise application error, but my code indicates :
Error code 1064, SQL state 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(-20000,'Pay is below Texas minimum wage!');
END IF;
END' at line 9
and if I remove the part of raise application error, it works perfectly .
Trigger:
DELIMITER @@
DROP TRIGGER IF EXISTS gmtt.after_update_mcorr @@
CREATE TRIGGER gmtt.after_update_mcorr
AFTER UPDATE ON gmtt.mcorr
FOR EACH ROW
BEGIN
IF OLD.etat = '0' AND NEW.etat = '1' THEN
INSERT INTO historique(message, User, dateHisto) VALUES (CONCAT( 'a achevé la Maintenance ', OLD.codeMaint) , CURRENT_USER(), NOW());
ELSE
raise_application_error(-20000,'Pay is below Texas minimum wage!');
END IF;
END @@
DELIMITER ;
Your syntax appears to be MySQL. And yet,
raise_application_error
is an Oracle construct. You wantsignal
, documented here: