I have the following situation:
Thetablesdescribedabovearerespectivelyger_usuario
,ger_mensagem
andger_destinos
.
Thefieldproprietario
(ger_mensagem
)isaFOREIGNKEYreferringtotheger_usuario
table.
Thefieldid_destino
(ger_mensagem
)isaFOREIGNKEYreferringtotheger_destinos
table.
IneedaTriggerthatfetchesthevalueofthelastid_destino
(ger_destinos
)toonlythenaddittotheger_mensagem
table.Inthiscasetheproprietario
willbecomparedviacode.
ImadethisTrigger:
DELIMITER$$CREATETRIGGERmanut_destinoBEFOREINSERTONger_mensagemFOREACHROWBEGINDECLAREvar_destINT;INSERTINTOger_destinosVALUES('','',0);SELECTid_destinoINTOvar_destFROMger_destinosORDERBYid_destinoDESC;INSERTINTOger_mensagemVALUES('','NEW.assunto','NEW.cat','NEW.rec','NEW.data_cria','NEW.del','NEW.del_nom','NEW.del_data',1,var_dest);end$$
Butithasthefollowingerror: