I'm trying to create a trigger in Mysql where I need to update a table (I'll call tb1) depending on the situation field, delete a record in another database from a table.
Base 1 = B1 Table 1 = Tb1 Base 2 = B2 Table 2 = Tb2
- trigger I'm trying to create
CREATE TRIGGER trigger_agendamento_vinculo_situacao AFTER UPDATE ON B1.TB1 for each row begin
if (new.situacao <> 'ativo') THEN
delete from B2.TB2 where username = NEW.prontuario_original;
end;
But whenever I try to create MySQL it has the following error:
CREATE TRIGGER B1.TB1.trigger_agendamento_vinculo_situacao AFTER UPDATE ON B1.TB1 for each row begin if (new.situation &>; 'active') THEN delete from B2.TB2 where username = NEW.Prontuario_original Error Code: 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 3 0.000 sec