sql - whats wrong with mysql tigger -
this trigger im trying add. keep getting "updating of new row not allowed in after trigger"
delimiter $$ drop trigger if exists leaderboard.badges_aupd$$ use leaderboard$$ create trigger `badges_aupd` after update on `badges` each row set new.badgelevel := case when badgepercent < 50 0 when badgepercent < 75 1 else 2 end; $$ delimiter ;
your trigger should before update
since after update cant set column of same table, , missing begin
part
delimiter $$ drop trigger if exists leaderboard.badges_aupd$$ use leaderboard$$ create trigger `badges_aupd` before update on `badges` each row begin if new.badgepercent < 50 set new.badgelevel = 0 ; elseif new.badgepercent < 75 set new.badgelevel = 1 ; else set new.badgelevel = 2; end if; end;$$ delimiter ;
Comments
Post a Comment