sql - Error 1064 on Mysql trigger -
i'm writing trigger in mysql take log of table updates. log table called individuo_storico , target table called individuo. when individuo updated, want check if idqualifica , idlivello changed, if yes record in individuo_storico inserted.
i write down code #1064 error, where's syntax error?
use ore; create trigger individuo_update after update on individuo each row begin if ( new.idlivello <> old.idlivello or new.idqualifica <> old.idqualifica) insert individuo_storico(idindividuo, idqualifica, idlivello) values (new.idindividuo, new.idqualifica, new.idlivello); end if; end;
1064 - have error in sql syntax; check manual corresponds mysql server version right syntax use near '' @ line 6
please wrap trigger creation monikers necessary db engine not choke on it. 3 areas:
1) line 1 2) right after end; 3) , reset default delimiter.
same concept typical stored proc creations.
delimiter $$ create trigger individuo_update after update on individuo each row begin if ( new.idlivello <> old.idlivello or new.idqualifica <> old.idqualifica) insert individuo_storico(idindividuo, idqualifica, idlivello) values (new.idindividuo, new.idqualifica, new.idlivello); end if; end;$$ delimiter ;
Comments
Post a Comment