1

m writing following lines for creating a trigger:

create trigger notify after insert on applications
for each row
begin
insert into notifications SET sno=1;
end;

but everytime i get following error:

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 '' at line 4

line 4 is - insert into notifications SET sno=1

1
  • Well, the INSERT query is wrong. Commented Apr 7, 2013 at 19:48

1 Answer 1

1

MySQL is confused about the delimiters. It thinks the first ; is the end of the TRIGGER declaration (which it is not). Use delimiter to change it temporarily, and later to change it back:

delimiter |
create trigger notify after insert on applications
for each row
begin
insert into notifications (sno) values (1);
end;
|
delimiter ;

More in the documentation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.