Home > Back-end >  create trigger syntax issue migrating mysql from 5.6 to 8
create trigger syntax issue migrating mysql from 5.6 to 8

Time:10-15

CREATE TRIGGER `set_avatar_null` BEFORE UPDATE ON `mybb_users`
 FOR EACH ROW begin
   if new.uid = -1 then
     Insert Into Log (uid, Page, Params, Time) values (new.uid, 'set_avatar_null',new.avatar,      NOW());
   set new.avatar = '', new.avatardimensions='';
  end if;
end

this syntax works fine in mysql 5.6, but in 8.0 throws this exception:

#1064 - 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

CodePudding user response:

Use the DELIMITER command to change the delimiter before the statement. See the db-fiddle.

  • Related