I have this trigger ( trigger ) named BEFORE UPDATE
in MySQL :
CREATE DEFINER='root'@'%' TRIGGER
'CalcularCamposCalculadosActuacionesU' BEFORE INSERT ON 'actuacion'
FOR EACH ROW BEGIN
SET NEW.TieneFiltrosValidos =
(select case when a.IdActuacion in
(select ac.IdActuacion from actuacion ac
left join MaestraEstado es on es.IdMaestraEstado = ac.IdMaestraEstado
where (((es.Valor <> "FIN") and (es.Valor <> "REVISA"))
or (ac.Incurrido2016 > 0)) and (es.Valor <> "ELIMINADO")
) then "Sí"
else "No"
end Valor
from actuacion a
where a.IdActuacion = NEW.IdActuacion);'
According to some conditions, taken from a master table, I want to fill the field of the entity actuacion
with a "Sí"
, if it meets the condition, and otherwise a "No"
.
On the trigger BEFORE UPDATE
, yes, I update this field, while on the insert, no.
I do not jump any errors or anything, just leave that field to null.