MySQL Trigger and Error Code 1362 -
so have following query trigger:
delimiter $$ create trigger user_log_update before update on user_log each row begin insert user_log (id, user_id, name, username, password, email, user_type_id, created) values(old.id, old.user_id, old.name, old.username, old.password, old.email, old.user_type_id, old.created); if (old.id = 1) set old.id = old.id +1; end if; select * user_log; end$$ delimiter ;
when try execute part of script, error code: 1362. updating of old row not allowed in trigger
i don't know why got error , don't see wrong in syntax.
does know how fix it?
so, increment new
instead:
delimiter $$ create trigger user_log_update before update on user_log each row begin insert user_log(id, user_id, name, username, password, email, user_type_id, created) values(old.id, old.user_id, old.name, old.username, old.password, old.email, old.user_type_id, old.created); if (old.id = 1) set new.id = old.id +1; end if; end$$ delimiter ;