CREATE OR ALTER trigger ttbcolaborador_b05u for tbcolaborador
active before update position 3
AS
BEGIN
  IF (OLD.SITUACAO IS DISTINCT FROM NEW.SITUACAO AND NEW.SITUACAO = '2') THEN
    BEGIN
        UPDATE TBOPERADOR O SET O.STATUS = '0' WHERE O.COLABORADOR_MATRICULA = NEW.CODIGO;
        UPDATE TBUSUARIO U SET U.STATUS = '0' WHERE U.COLABORADOR_ID = NEW.CODIGO;
    END

  IF (OLD.SITUACAO IS DISTINCT FROM NEW.SITUACAO AND NEW.SITUACAO = '1') THEN
    BEGIN
        UPDATE TBOPERADOR O SET O.STATUS = '1' WHERE O.COLABORADOR_MATRICULA = NEW.CODIGO;
        UPDATE TBUSUARIO U SET U.STATUS = '1' WHERE U.COLABORADOR_ID = NEW.CODIGO;
    END
END;