---------------------------------------------
CREATE OR REPLACE TRIGGER ATUALIZA_UPDATE_OPERADOR BEFORE UPDATE ON ITLANCTOEST
FOR EACH ROW
BEGIN
   SELECT MAX(CDOPERADOR)
   INTO :NEW.CDOPERADOR
   FROM LANCTOESTOQ
   WHERE CDFILIAL   = :NEW.CDFILIAL AND
         NRLANCESTQ = :NEW.NRLANCESTQ;

   IF :NEW.IDTIPOMOVI = '3' THEN
      :NEW.IDORDEMCLC := '9';
   ELSIF :NEW.IDTIPOMOVI = '4' THEN
      :NEW.IDORDEMCLC := '8';
   ELSIF :NEW.IDTIPOMOVI = '5' THEN
      :NEW.IDORDEMCLC := '7';
   END IF;
END;
/

