Why does this not work?  How can I do it?

CREATE TRIGGER tr_encounter_lab_order_upd
   AFTER UPDATE ON encounter_lab_order
   FOR EACH ROW
    if (      new.DX_CODE != old.DX_CODE or
            ( new.DX_CODE is null and old.DX_CODE is 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;

The error I'm getting is:
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 'update
encounter_order
       set          dx_code = new.dx_code
      ' at line 5

Chris
Mysql 5.0.41

Reply via email to