Mysql Error when creating trigger -


error note:error : have error in sql syntax; check manual corresponds mysql server version right syntax use near '@sum int default 0;     set @sum=(select count(*) inserted);     if @sum>1     ' @ line 5 

and code:

delimiter //  create trigger insert_only_one  after insert on sc  each row  begin  declare @sum int default 0;  set @sum=(select count(*) inserted);  if @sum>1  print('dont insert more 1 record');  rollback transaction  end 

the error note shows have error @ line 5. tried int(5) or 'int', or without default 0 still can't work.

you don't need declare variable because using @sum variable initialized automatically..

you can't print inside trigger...

also command rollback transaction invalid mysql. use rollback semicolon..


Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -