I have the following trigger in Postgresql, how can we do this in Mysql?
CREATE TRIGGER tr_encounter_lab_order_upd
AFTER UPDATE ON encounter_lab_order
FOR EACH ROW
EXECUTE PROCEDURE tr_encounter_lab_order_upd_trig_func();
CREATE OR REPLACE FUNCTION tr_encounter_lab_order_upd_trig_func()
RETURNS "trigger" AS
$BODY$
begin
if (new.DX_CODE != old.DX_CODE or (new.DX_CODE is null and
old.DX_CODEis not null) or (
new.DX_CODE is not null and old.DX_CODE is null)) then
update encounter_order set
dx_code = new.dx_code where
encounter_id = new.encounter_id and
order_id = new.order_id;
end if;
return new;
end;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
Can Mysql handle this if logic needed by this trigger, or only fire if a
specific column is updated?
Thanks,
Chris