Reputation: 588
Hi i'm trying to create below trigger
CREATE TRIGGER TRIGBEFORE INSERT ON employee FOR EACH ROW BEGIN UPDATE employee SET userId = userId +1 WHERE userId >1; END
it is giving me below mysql error, please suggest what is wrong in it.
Upvotes: 0
Views: 94
Reputation: 204746
you forgot to set the delimiter and misspelled a word:
delimiter |
CREATE TRIGGER TRIG BEFORE INSERT ON employee
FOR EACH ROW BEGIN
UPDATE employee SET userId = userId +1 WHERE userId >1;
END;
|
delimiter ;
If you don't set another delimiter than ;
the statement will end at the first ;
and your trigger definition will be incomplete. You need to tell MySQL that the stamentment should end at the delimiter you defined. After that you can set the delimiter back with delimiter ;
Upvotes: 2
Reputation: 29061
I think you have a typo mistake TRIGBEFORE
: manual here
CREATE TRIGGER trigger_name BEFORE INSERT ON ...
Upvotes: 0