create or replace
TRIGGER LOG_FIS_IMPOSTO
AFTER DELETE OR INSERT OR UPDATE
ON IMPOSTO FOR EACH ROW
DECLARE
  V_DSREMOTEADDR VARCHAR2(15);
  V_DSREMOTEHOST VARCHAR2(15);
  V_DSSERVERRDM  VARCHAR2(20);
  V_DSSERVMETHOD VARCHAR2(30);
  V_DSREMOTEOPER VARCHAR2(12);
  V_USUARIO   VARCHAR2(40);
  V_TIPO      VARCHAR2(1);
  V_ITPESQ    VARCHAR2(40);
  V_DESC      VARCHAR2(1000);
  V_DTOPER    DATE;
BEGIN
   V_TIPO := '0';
   V_DESC := '';

   IF DELETING THEN
      IF :OLD.VRPERCADICIR IS NOT NULL THEN
         V_DESC := V_DESC || ' AdIr=' || :OLD.VRPERCADICIR;
      END IF;

      IF :OLD.IDMODBCSTNFE IS NOT NULL THEN
         V_DESC := V_DESC || ' IdModBCSTNFE=' || :OLD.IDMODBCSTNFE;
      END IF;

      IF :OLD.IDMODBCNFE IS NOT NULL THEN
         V_DESC := V_DESC || ' IdModBCNFE=' || :OLD.IDMODBCNFE;
      END IF;

      IF :OLD.CDIMPOSTOXML IS NOT NULL THEN
         V_DESC := V_DESC || ' CdImpXml=' || :OLD.CDIMPOSTOXML;
      END IF;

      IF :OLD.IDCONSVRBAPUIMP IS NOT NULL THEN
         V_DESC := V_DESC || ' IdConsVrImp=' || :OLD.IDCONSVRBAPUIMP;
      END IF;

      IF :OLD.CDIMPOSTO IS NOT NULL THEN
         V_DESC := V_DESC || ' CdImposto=' || :OLD.CDIMPOSTO;
      END IF;

      IF :OLD.CDFORNECED IS NOT NULL THEN
         V_DESC := V_DESC || ' CdForneced=' || :OLD.CDFORNECED;
      END IF;

      IF :OLD.IDATUCCTBITIMP IS NOT NULL THEN
         V_DESC := V_DESC || ' IdAtuImp=' || :OLD.IDATUCCTBITIMP;
      END IF;

      IF :OLD.CDTIPOPERFATU IS NOT NULL THEN
         V_DESC := V_DESC || ' TpOp=' || :OLD.CDTIPOPERFATU;
      END IF;

      IF :OLD.VRLIMADICLCPR IS NOT NULL THEN
         V_DESC := V_DESC || ' VlrLimAd=' || :OLD.VRLIMADICLCPR;
      END IF;

      IF :OLD.VRALIQIMPLCPR IS NOT NULL THEN
         V_DESC := V_DESC || ' AliqImp=' || :OLD.VRALIQIMPLCPR;
      END IF;

      IF :OLD.VRALIQPRES IS NOT NULL THEN
         V_DESC := V_DESC || ' AliqPre=' || :OLD.VRALIQPRES;
      END IF;

      IF :OLD.IDTRATIMPO IS NOT NULL THEN
         V_DESC := V_DESC || ' Benefic=' || :OLD.IDTRATIMPO;
      END IF;

      IF :OLD.CDTRIBISSQN IS NOT NULL THEN
         V_DESC := V_DESC || ' CdTrib=' || :OLD.CDTRIBISSQN;
      END IF;

      IF :OLD.IDGRUPFISSRV IS NOT NULL THEN
         V_DESC := V_DESC || ' FisServ=' || :OLD.IDGRUPFISSRV;
      END IF;

      IF :OLD.IDIMPVALIDASPED IS NOT NULL THEN
         V_DESC := V_DESC || ' VldSpd=' || :OLD.IDIMPVALIDASPED;
      END IF;

      IF :OLD.IDUTFORMPADIMP IS NOT NULL THEN
         V_DESC := V_DESC || ' FormApr=' || :OLD.IDUTFORMPADIMP;
      END IF;

      IF :OLD.CDTPBAIXAPAG IS NOT NULL THEN
         V_DESC := V_DESC || ' BaixPag=' || :OLD.CDTPBAIXAPAG;
      END IF;

      IF :OLD.IDVRIMPSTRIB IS NOT NULL THEN
         V_DESC := V_DESC || ' VlrImpTrib=' || :OLD.IDVRIMPSTRIB;
      END IF;

      IF :OLD.NMLUCROPRESUMI IS NOT NULL THEN
         V_DESC := V_DESC || ' NmLucrPres=' || :OLD.NMLUCROPRESUMI;
      END IF;

      IF :OLD.NMIMPCARGATRIB IS NOT NULL THEN
         V_DESC := V_DESC || ' NmImpCargTrib=' || :OLD.NMIMPCARGATRIB;
      END IF;

      IF :OLD.CDLUCROPRESUMI IS NOT NULL THEN
         V_DESC := V_DESC || ' LucrPres=' || :OLD.CDLUCROPRESUMI;
      END IF;

      IF :OLD.CDIMPCARGATRIB IS NOT NULL THEN
         V_DESC := V_DESC || ' ImpoCarg=' || :OLD.CDIMPCARGATRIB;
      END IF;

      IF :OLD.VRMINBASECAL IS NOT NULL THEN
         V_DESC := V_DESC || ' VlrMens=' || :OLD.VRMINBASECAL;
      END IF;

      IF :OLD.IDUTVRMENSBC IS NOT NULL THEN
         V_DESC := V_DESC || ' VlrMens=' || :OLD.IDUTVRMENSBC;
      END IF;

      IF :OLD.IDCONTAIMPADIC IS NOT NULL THEN
         V_DESC := V_DESC || ' ImpoAdc=' || :OLD.IDCONTAIMPADIC;
      END IF;

      IF :OLD.ID1UTREDUBC IS NOT NULL THEN
         V_DESC := V_DESC || ' RedCalc=' || :OLD.ID1UTREDUBC;
      END IF;

      IF :OLD.IDUTVLRQTDEIMPO IS NOT NULL THEN
         V_DESC := V_DESC || ' VlrQtd=' || :OLD.IDUTVLRQTDEIMPO;
      END IF;

      IF :OLD.CDAJUCTPAG IS NOT NULL THEN
         V_DESC := V_DESC || ' AjucTpag=' || :OLD.CDAJUCTPAG;
      END IF;

      IF :OLD.CDOFICIMPO IS NOT NULL THEN
         V_DESC := V_DESC || ' CodOfici=' || :OLD.CDOFICIMPO;
      END IF;

      IF :OLD.IDACRPRODENTRNF IS NOT NULL THEN
         V_DESC := V_DESC || ' AcrPro=' || :OLD.IDACRPRODENTRNF;
      END IF;

      IF :OLD.NMIMPOSTO IS NOT NULL THEN
         V_DESC := V_DESC || ' NomeImpo=' || :OLD.NMIMPOSTO;
      END IF;

      IF :OLD.SGIMPOSTO IS NOT NULL THEN
         V_DESC := V_DESC || ' SiglaImpo=' || :OLD.SGIMPOSTO;
      END IF;

      IF :OLD.IDTIPCONTAB IS NOT NULL THEN
         V_DESC := V_DESC || ' TipoContab=' || :OLD.IDTIPCONTAB;
      END IF;

      IF :OLD.IDPRODNOTA IS NOT NULL THEN
         V_DESC := V_DESC || ' ProdNota=' || :OLD.IDPRODNOTA;
      END IF;

      IF :OLD.IDUTMUNIORIG IS NOT NULL THEN
         V_DESC := V_DESC || ' MuniOrig=' || :OLD.IDUTMUNIORIG;
      END IF;

      IF :OLD.IDUTUFORIG IS NOT NULL THEN
         V_DESC := V_DESC || ' UFOrig=' || :OLD.IDUTUFORIG;
      END IF;

      IF :OLD.IDUTUFDEST IS NOT NULL THEN
         V_DESC := V_DESC || ' UFDest=' || :OLD.IDUTUFDEST;
      END IF;

      IF :OLD.IDUTFAIXVLR IS NOT NULL THEN
         V_DESC := V_DESC || ' FaixVR=' || :OLD.IDUTFAIXVLR;
      END IF;

      IF :OLD.IDUTPARCDED IS NOT NULL THEN
         V_DESC := V_DESC || ' ParcDed=' || :OLD.IDUTPARCDED;
      END IF;

      IF :OLD.IDUTREDUBC IS NOT NULL THEN
         V_DESC := V_DESC || ' RedBC=' || :OLD.IDUTREDUBC;
      END IF;

      IF :OLD.IDIMPORECUP IS NOT NULL THEN
         V_DESC := V_DESC || ' ImpoRecup=' || :OLD.IDIMPORECUP;
      END IF;

      IF :OLD.CDCCTBLDESP IS NOT NULL THEN
         V_DESC := V_DESC || ' CCtbDesp=' || :OLD.CDCCTBLDESP;
      END IF;

      IF :OLD.CDCCTBLPASS IS NOT NULL THEN
         V_DESC := V_DESC || ' CCtbPass=' || :OLD.CDCCTBLPASS;
      END IF;

      IF :OLD.CDCCTBLATIV IS NOT NULL THEN
         V_DESC := V_DESC || ' CCtbPass=' || :OLD.CDCCTBLATIV;
      END IF;

      IF :OLD.CDCCTBLDADM IS NOT NULL THEN
         V_DESC := V_DESC || ' CCtbADM=' || :OLD.CDCCTBLDADM;
      END IF;

      IF :OLD.IDCONSISTENT IS NOT NULL THEN
         V_DESC := V_DESC || ' ConsEntr=' || :OLD.IDCONSISTENT;
      END IF;

      IF :OLD.IDORGARRECAD IS NOT NULL THEN
         V_DESC := V_DESC || ' OrgArrecad=' || :OLD.IDORGARRECAD;
      END IF;

      IF :OLD.CDIMPOSAPUR IS NOT NULL THEN
         V_DESC := V_DESC || ' ImposApur=' || :OLD.CDIMPOSAPUR;
      END IF;

      IF :OLD.CDAJUCTREC IS NOT NULL THEN
         V_DESC := V_DESC || ' AjCtReceb=' || :OLD.CDAJUCTREC;
      END IF;

      IF :OLD.IDDESCRFONTE IS NOT NULL THEN
         V_DESC := V_DESC || ' DesCRFonte=' || :OLD.IDDESCRFONTE;
      END IF;

      IF :OLD.IDPREIMPENTR IS NOT NULL THEN
         V_DESC := V_DESC || ' PreImpEntr=' || :OLD.IDPREIMPENTR;
      END IF;

      IF :OLD.CDINTIMPOSTO IS NOT NULL THEN
         V_DESC := V_DESC || ' IntImposto=' || :OLD.CDINTIMPOSTO;
      END IF;

      IF :OLD.CDIMPOSTRIB IS NOT NULL THEN
         V_DESC := V_DESC || ' ImposTrib=' || :OLD.CDIMPOSTRIB;
      END IF;

      IF :OLD.CDTPCTPAGAR IS NOT NULL THEN
         V_DESC := V_DESC || ' TpCtPagar=' || :OLD.CDTPCTPAGAR;
      END IF;

      IF :OLD.IDTPIMPOSFIS IS NOT NULL THEN
         V_DESC := V_DESC || ' TpImposFis=' || :OLD.IDTPIMPOSFIS;
      END IF;

      IF :OLD.IDFORMAPUR IS NOT NULL THEN
         V_DESC := V_DESC || ' FormApur=' || :OLD.IDFORMAPUR;
      END IF;

      IF :OLD.IDUTALIQTPOPER IS NOT NULL THEN
         V_DESC := V_DESC || ' UtAliqTpOp=' || :OLD.IDUTALIQTPOPER;
      END IF;

      IF :OLD.CDIMPOSTONFE IS NOT NULL THEN
         V_DESC := V_DESC || ' CdImpostoNFE=' || :OLD.CDIMPOSTONFE;
      END IF;

      IF :OLD.IDDESONERAIMPO IS NOT NULL THEN
         V_DESC := V_DESC || ' IdDesoneraImpo=' || :OLD.IDDESONERAIMPO;
      END IF;

      IF :OLD.IDUTCFOPREGFISC IS NOT NULL THEN
         V_DESC := V_DESC || ' Utiliza CFOP=' || :OLD.IDUTCFOPREGFISC;
      END IF;

      IF :OLD.IDUTCSTREGFISC IS NOT NULL THEN
         V_DESC := V_DESC || ' Utiliza CST=' || :OLD.IDUTCSTREGFISC;
      END IF;

      IF :OLD.IDUTVRPAUTA IS NOT NULL THEN
         V_DESC := V_DESC || ' UtVrPautaFisc=' || :OLD.IDUTVRPAUTA;
      END IF;

      IF :OLD.IDUTILPVRIMPBC  IS NOT NULL THEN
         V_DESC := V_DESC || ' UtVrImpBCalc=' || :OLD.IDUTILPVRIMPBC;
      END IF;

      IF :OLD.VRMAXIMP  IS NOT NULL THEN
         V_DESC := V_DESC || ' VrMaxImp=' || :OLD.VRMAXIMP;
      END IF;

      IF :OLD.IDCALCBCMENSDIA  IS NOT NULL THEN
         V_DESC := V_DESC || ' IdCalcBCMensDia=' || :OLD.IDCALCBCMENSDIA;
      END IF;

      IF :OLD.IDPERALIQDIFXML  IS NOT NULL THEN
         V_DESC := V_DESC || ' IdPerAliqDifXml=' || :OLD.IDPERALIQDIFXML;
      END IF;

      IF :OLD.DSESTCALCDIFAL  IS NOT NULL THEN
         V_DESC := V_DESC || ' NCalcDifalLanctoNF=' || :OLD.DSESTCALCDIFAL;
      END IF;

      IF :OLD.DSESTDIFALDENT  IS NOT NULL THEN
         V_DESC := V_DESC || ' CalcDifalDentroLanctoNF=' || :OLD.DSESTDIFALDENT;
      END IF;

      IF :OLD.IDGERVRDADOSADIC  IS NOT NULL THEN
         V_DESC := V_DESC || ' IdGerVrDadosAdic=' || :OLD.IDGERVRDADOSADIC;
      END IF;

      IF :OLD.DSVRDADOSADICTPOP  IS NOT NULL THEN
         V_DESC := V_DESC || ' DsVrDadosAdicTpOp=' || :OLD.DSVRDADOSADICTPOP;
      END IF;

      V_TIPO := '3';
      V_ITPESQ := :OLD.CDIMPOSTO;
   ELSE
      IF UPDATING THEN
        IF (NVL(:NEW.IDTRATIMPO, '!') <> NVL(:OLD.IDTRATIMPO, '!'))                 OR
           (NVL(:NEW.IDMODBCSTNFE, '!') <> NVL(:OLD.IDMODBCSTNFE, '!'))             OR
           (NVL(:NEW.CDIMPOSTOXML, '!') <> NVL(:OLD.CDIMPOSTOXML, '!'))             OR
           (NVL(:NEW.IDCONSVRBAPUIMP, '!') <> NVL(:OLD.IDCONSVRBAPUIMP, '!'))       OR
           (NVL(:NEW.CDIMPOSTO, '!') <> NVL(:OLD.CDIMPOSTO, '!'))                   OR
           (NVL(:NEW.CDFORNECED, '!') <> NVL(:OLD.CDFORNECED, '!'))                 OR
           (NVL(:NEW.IDACRPRODENTRNF, '!') <> NVL(:OLD.IDACRPRODENTRNF, '!'))       OR
           (NVL(:NEW.CDOFICIMPO, '!') <> NVL(:OLD.CDOFICIMPO, '!'))                 OR
           (NVL(:NEW.NMIMPOSTO , '!') <> NVL(:OLD.NMIMPOSTO , '!'))                 OR
           (NVL(:NEW.CDAJUCTPAG , '!') <> NVL(:OLD.CDAJUCTPAG , '!'))               OR
           (NVL(:NEW.SGIMPOSTO, '!') <> NVL(:OLD.SGIMPOSTO , '!'))                  OR
           (NVL(:NEW.VRMINBASECAL, -1) <> NVL(:OLD.VRMINBASECAL, -1))               OR
           (NVL(:NEW.IDCONTAIMPADIC, '!') <> NVL(:OLD.IDCONTAIMPADIC , '!'))        OR
           (NVL(:NEW.CDIMPCARGATRIB , '!') <> NVL(:OLD.CDIMPCARGATRIB  , '!'))      OR
           (NVL(:NEW.NMIMPCARGATRIB , '!') <> NVL(:OLD.NMIMPCARGATRIB  , '!'))      OR
           (NVL(:NEW.IDTIPCONTAB , '!') <> NVL(:OLD.IDTIPCONTAB  , '!'))            OR
           (NVL(:NEW.ID1UTREDUBC , '!') <> NVL(:OLD.ID1UTREDUBC  , '!'))            OR
           (NVL(:NEW.CDLUCROPRESUMI , '!') <> NVL(:OLD.CDLUCROPRESUMI , '!'))       OR
           (NVL(:NEW.IDUTFORMPADIMP , '!') <> NVL(:OLD.IDUTFORMPADIMP  , '!'))      OR
           (NVL(:NEW.IDPRODNOTA , '!') <> NVL(:OLD.IDPRODNOTA , '!'))               OR
           (NVL(:NEW.IDUTMUNIORIG , '!') <> NVL(:OLD.IDUTMUNIORIG , '!'))           OR
           (NVL(:NEW.IDUTVLRQTDEIMPO , '!') <> NVL(:OLD.IDUTVLRQTDEIMPO  , '!'))    OR
           (NVL(:NEW.IDUTUFORIG , '!') <> NVL(:OLD.IDUTUFORIG  , '!'))              OR
           (NVL(:NEW.IDUTUFDEST , '!') <> NVL(:OLD.IDUTUFDEST  , '!'))              OR
           (NVL(:NEW.IDUTFAIXVLR  , '!') <> NVL(:OLD.IDUTFAIXVLR   , '!'))          OR
           (NVL(:NEW.IDVRIMPSTRIB  , '!') <> NVL(:OLD.IDVRIMPSTRIB   , '!'))        OR
           (NVL(:NEW.IDATUCCTBITIMP  , '!') <> NVL(:OLD.IDATUCCTBITIMP   , '!'))    OR
           (NVL(:NEW.IDUTUFDEST  , '!') <> NVL(:OLD.IDUTUFDEST   , '!'))            OR
           (NVL(:NEW.CDTRIBISSQN  , '!') <> NVL(:OLD.CDTRIBISSQN   , '!'))          OR
           (NVL(:NEW.IDUTPARCDED  , '!') <> NVL(:OLD.IDUTPARCDED   , '!'))          OR
           (NVL(:NEW.CDTPBAIXAPAG  , '!') <> NVL(:OLD.CDTPBAIXAPAG   , '!'))        OR
           (NVL(:NEW.VRALIQPRES, -1) <> NVL(:OLD.VRALIQPRES, -1))                   OR
           (NVL(:NEW.VRPERCADICIR, -1) <> NVL(:OLD.VRPERCADICIR, -1))               OR
           (NVL(:NEW.CDTIPOPERFATU  , '!') <> NVL(:OLD.CDTIPOPERFATU   , '!'))      OR
           (NVL(:NEW.IDIMPVALIDASPED  , '!') <> NVL(:OLD.IDIMPVALIDASPED   , '!'))  OR
           (NVL(:NEW.IDGRUPFISSRV  , '!') <> NVL(:OLD.IDGRUPFISSRV   , '!'))        OR
           (NVL(:NEW.IDUTVRMENSBC  , '!') <> NVL(:OLD.IDUTVRMENSBC   , '!'))        OR
           (NVL(:NEW.IDUTREDUBC  , '!') <> NVL(:OLD.IDUTREDUBC   , '!'))            OR
           (NVL(:NEW.IDIMPORECUP  , '!') <> NVL(:OLD.IDIMPORECUP   , '!'))          OR
           (NVL(:NEW.VRALIQIMPLCPR, -1) <> NVL(:OLD.VRALIQIMPLCPR, -1))             OR
           (NVL(:NEW.VRLIMADICLCPR, -1) <> NVL(:OLD.VRLIMADICLCPR, -1))             OR
           (NVL(:NEW.IDCONSISTENT  , '!') <> NVL(:OLD.IDCONSISTENT   , '!'))        OR
           (NVL(:NEW.IDORGARRECAD  , '!') <> NVL(:OLD.IDORGARRECAD   , '!'))        OR
           (NVL(:NEW.CDIMPOSAPUR  , '!') <> NVL(:OLD.CDIMPOSAPUR   , '!'))          OR
           (NVL(:NEW.CDAJUCTREC  , '!') <> NVL(:OLD.CDAJUCTREC    , '!'))           OR
           (NVL(:NEW.IDDESCRFONTE  , '!') <> NVL(:OLD.IDDESCRFONTE   , '!'))        OR
           (NVL(:NEW.IDPREIMPENTR   , '!') <> NVL(:OLD.IDPREIMPENTR    , '!'))      OR
           (NVL(:NEW.NMLUCROPRESUMI  , '!') <> NVL(:OLD.NMLUCROPRESUMI   , '!'))    OR
           (NVL(:NEW.CDINTIMPOSTO   , '!') <> NVL(:OLD.CDINTIMPOSTO   , '!'))       OR
           (NVL(:NEW.CDIMPOSTRIB   , '!') <> NVL(:OLD.CDIMPOSTRIB    , '!'))        OR
           (NVL(:NEW.CDTPCTPAGAR  , '!') <> NVL(:OLD.CDTPCTPAGAR   , '!'))          OR
           (NVL(:NEW.IDTPIMPOSFIS  , '!') <> NVL(:OLD.IDTPIMPOSFIS   , '!'))        OR
           (NVL(:NEW.IDFORMAPUR  , '!') <> NVL(:OLD.IDFORMAPUR   , '!'))            OR
           (NVL(:NEW.IDDESONERAIMPO  , '!') <> NVL(:OLD.IDDESONERAIMPO   , '!'))    OR
           (NVL(:NEW.IDUTALIQTPOPER  , '!') <> NVL(:OLD.IDUTALIQTPOPER   , '!'))    OR
           (NVL(:NEW.IDUTCFOPREGFISC  , '!') <> NVL(:OLD.IDUTCFOPREGFISC   , '!'))  OR
           (NVL(:NEW.IDUTCSTREGFISC  , '!') <> NVL(:OLD.IDUTCSTREGFISC   , '!'))    OR
           (NVL(:NEW.IDUTFAIXVLR  , '!') <> NVL(:OLD.IDUTFAIXVLR   , '!'))          OR
           (NVL(:OLD.CDCCTBLDESP,'!')   <> NVL(:NEW.CDCCTBLDESP,'!'))               OR
           (NVL(:OLD.CDCCTBLPASS,'!')   <> NVL(:NEW.CDCCTBLPASS,'!'))               OR
           (NVL(:OLD.CDCCTBLATIV,'!')   <> NVL(:NEW.CDCCTBLATIV,'!'))               OR
           (NVL(:OLD.CDCCTBLDADM,'!')   <> NVL(:NEW.CDCCTBLDADM,'!'))               OR
           (NVL(:OLD.CDIMPOSTONFE, '!') <> NVL(:NEW.CDIMPOSTONFE, '!'))             OR
           (NVL(:OLD.IDUTILPVRIMPBC, '!') <> NVL(:NEW.IDUTILPVRIMPBC, '!'))         OR
           (NVL(:OLD.IDUTVRPAUTA, '!') <> NVL(:NEW.IDUTVRPAUTA, '!'))               OR
           (NVL(:OLD.IDCALCBCMENSDIA, '!') <>  NVL(:NEW.IDCALCBCMENSDIA, '!'))      OR
           (NVL(:OLD.IDPERALIQDIFXML, '!') <>  NVL(:NEW.IDPERALIQDIFXML, '!'))      OR
           (NVL(:NEW.VRMAXIMP, -1) <> NVL(:OLD.VRMAXIMP, -1))                       OR
           (NVL(:OLD.DSESTCALCDIFAL, '!') <> NVL(:NEW.DSESTCALCDIFAL, '!'))         OR
           (NVL(:OLD.DSESTDIFALDENT, '!') <> NVL(:NEW.DSESTDIFALDENT, '!'))         OR
           (NVL(:OLD.IDGERVRDADOSADIC, '!') <> NVL(:NEW.IDGERVRDADOSADIC, '!'))     OR
           (NVL(:OLD.DSVRDADOSADICTPOP, '!') <> NVL(:NEW.DSVRDADOSADICTPOP, '!'))   THEN
            V_TIPO   := '2';
            V_ITPESQ := :OLD.CDIMPOSTO;
         END IF;
      ELSE
         V_TIPO   := '1';
         V_ITPESQ := :NEW.CDIMPOSTO;
      END IF;

      IF NVL(:NEW.IDTRATIMPO, '!') <> NVL(:OLD.IDTRATIMPO, '!')           THEN
         V_DESC := V_DESC || ' TratImpo=' || :NEW.IDTRATIMPO;
      END IF;

      IF NVL(:NEW.IDMODBCSTNFE, '!') <> NVL(:OLD.IDMODBCSTNFE, '!')       THEN
         V_DESC := V_DESC || ' IdModBCSTNFE=' || :NEW.IDMODBCSTNFE;
      END IF;

      IF NVL(:NEW.IDMODBCNFE, '!') <> NVL(:OLD.IDMODBCNFE, '!')           THEN
         V_DESC := V_DESC || ' IdModBCNFE=' || :NEW.IDMODBCNFE;
      END IF;

      IF NVL(:NEW.CDIMPOSTOXML, '!') <> NVL(:OLD.CDIMPOSTOXML, '!')       THEN
         V_DESC := V_DESC || ' CdImpXml=' || :NEW.CDIMPOSTOXML;
      END IF;

      IF NVL(:NEW.IDCONSVRBAPUIMP, '!') <> NVL(:OLD.IDCONSVRBAPUIMP, '!') THEN
         V_DESC := V_DESC || ' IdConsVrImp=' || :NEW.IDCONSVRBAPUIMP;
      END IF;

      IF NVL(:NEW.CDIMPOSTO, '!') <> NVL(:OLD.CDIMPOSTO, '!')             THEN
         V_DESC := V_DESC || ' CdImposto=' || :NEW.CDIMPOSTO;
      END IF;

      IF NVL(:NEW.CDFORNECED, '!') <> NVL(:OLD.CDFORNECED, '!')           THEN
         V_DESC := V_DESC || ' CdForneced=' || :NEW.CDFORNECED;
      END IF;

      IF NVL(:NEW.IDATUCCTBITIMP, '!') <> NVL(:OLD.IDATUCCTBITIMP, '!')   THEN
         V_DESC := V_DESC || ' IdAtuImp=' || :NEW.IDATUCCTBITIMP;
      END IF;

      IF NVL(:NEW.VRALIQPRES, -1) <> NVL(:OLD.VRALIQPRES, -1)             THEN
         V_DESC := V_DESC || ' AliqPre=' || :NEW.VRALIQPRES;
      END IF;

      IF NVL(:NEW.VRALIQIMPLCPR, -1) <> NVL(:OLD.VRALIQIMPLCPR, -1)       THEN
         V_DESC := V_DESC || ' AliqImp=' || :NEW.VRALIQIMPLCPR;
      END IF;

      IF NVL(:NEW.VRLIMADICLCPR, -1) <> NVL(:OLD.VRLIMADICLCPR, -1)       THEN
         V_DESC := V_DESC || ' AliqPre=' || :NEW.VRLIMADICLCPR;
      END IF;

      IF NVL(:NEW.VRPERCADICIR, -1) <> NVL(:OLD.VRPERCADICIR, -1)         THEN
         V_DESC := V_DESC || ' AdIr=' || :NEW.VRPERCADICIR;
      END IF;

      IF NVL(:NEW.CDTIPOPERFATU, '!') <> NVL(:OLD.CDTIPOPERFATU, '!')     THEN
         V_DESC := V_DESC || ' TpOp=' || :NEW.CDTIPOPERFATU;
      END IF;

      IF NVL(:NEW.CDLUCROPRESUMI, '!') <> NVL(:OLD.CDLUCROPRESUMI, '!')   THEN
         V_DESC := V_DESC || ' LucrPres=' || :NEW.CDLUCROPRESUMI;
      END IF;

      IF NVL(:NEW.IDUTFORMPADIMP, '!') <> NVL(:OLD.IDUTFORMPADIMP, '!')   THEN
         V_DESC := V_DESC || ' FormApr=' || :NEW.IDUTFORMPADIMP;
      END IF;

      IF NVL(:NEW.CDTRIBISSQN, '!') <> NVL(:OLD.CDTRIBISSQN, '!')         THEN
         V_DESC := V_DESC || ' CdTrib=' || :NEW.CDTRIBISSQN;
      END IF;

      IF NVL(:NEW.IDGRUPFISSRV, '!') <> NVL(:OLD.IDGRUPFISSRV, '!')       THEN
         V_DESC := V_DESC || ' FisServ=' || :NEW.IDGRUPFISSRV;
      END IF;

      IF NVL(:NEW.IDIMPVALIDASPED, '!') <> NVL(:OLD.IDIMPVALIDASPED, '!') THEN
         V_DESC := V_DESC || ' VldSpd=' || :NEW.IDIMPVALIDASPED;
      END IF;

      IF NVL(:NEW.CDTPBAIXAPAG, '!') <> NVL(:OLD.CDTPBAIXAPAG, '!')       THEN
         V_DESC := V_DESC || ' BaixPag=' || :NEW.CDTPBAIXAPAG;
      END IF;

      IF NVL(:NEW.IDVRIMPSTRIB, '!') <> NVL(:OLD.IDVRIMPSTRIB, '!')       THEN
         V_DESC := V_DESC || ' VlrImpTrib=' || :NEW.IDVRIMPSTRIB;
      END IF;

      IF NVL(:NEW.NMLUCROPRESUMI, '!') <> NVL(:OLD.NMLUCROPRESUMI, '!')   THEN
         V_DESC := V_DESC || ' NmLucrPres=' || :NEW.NMLUCROPRESUMI;
      END IF;

      IF NVL(:NEW.IDUTVLRQTDEIMPO, '!') <> NVL(:OLD.IDUTVLRQTDEIMPO, '!') THEN
         V_DESC := V_DESC || ' VlrQtd=' || :NEW.IDUTVLRQTDEIMPO;
      END IF;

      IF NVL(:NEW.NMIMPCARGATRIB, '!') <> NVL(:OLD.NMIMPCARGATRIB, '!')   THEN
         V_DESC := V_DESC || ' NmImpCargTrib=' || :NEW.NMIMPCARGATRIB;
      END IF;

      IF NVL(:NEW.IDUTVRMENSBC, '!') <> NVL(:OLD.IDUTVRMENSBC, '!')       THEN
         V_DESC := V_DESC || ' VlrMens=' || :NEW.IDUTVRMENSBC;
      END IF;

      IF NVL(:NEW.CDIMPCARGATRIB, '!') <> NVL(:OLD.CDIMPCARGATRIB, '!')   THEN
         V_DESC := V_DESC || ' ImpoCarg=' || :NEW.CDIMPCARGATRIB;
      END IF;

      IF NVL(:NEW.VRMINBASECAL, -1) <> NVL(:OLD.VRMINBASECAL, -1)         THEN
         V_DESC := V_DESC || ' VlrMens=' || :NEW.VRMINBASECAL;
      END IF;

      IF NVL(:NEW.IDCONTAIMPADIC, '!') <> NVL(:OLD.IDCONTAIMPADIC, '!')   THEN
         V_DESC := V_DESC || ' ImpoAdc=' || :NEW.IDCONTAIMPADIC;
      END IF;

      IF NVL(:NEW.ID1UTREDUBC, '!') <> NVL(:OLD.ID1UTREDUBC, '!')         THEN
         V_DESC := V_DESC || ' RedCalc=' || :NEW.ID1UTREDUBC;
      END IF;

      IF NVL(:NEW.CDAJUCTPAG , '!') <> NVL(:OLD.CDAJUCTPAG , '!')         THEN
         V_DESC := V_DESC || ' AjucTpag=' || :NEW.CDAJUCTPAG ;
      END IF;

      IF NVL(:NEW.CDOFICIMPO, '!') <> NVL(:OLD.CDOFICIMPO, '!')           THEN
         V_DESC := V_DESC || ' CodOfici=' || :NEW.CDOFICIMPO;
      END IF;

      IF NVL(:NEW.IDACRPRODENTRNF, '!') <> NVL(:OLD.IDACRPRODENTRNF, '!') THEN
         V_DESC := V_DESC || ' AcrProd=' || :NEW.IDACRPRODENTRNF;
      END IF;

      IF NVL(:NEW.NMIMPOSTO, '!') <> NVL(:OLD.NMIMPOSTO, '!')             THEN
         V_DESC := V_DESC || ' NomeImpo=' || :NEW.NMIMPOSTO;
      END IF;

      IF NVL(:NEW.SGIMPOSTO, '!') <> NVL(:OLD.SGIMPOSTO, '!')             THEN
         V_DESC := V_DESC || ' SiglaImpo=' || :NEW.SGIMPOSTO;
      END IF;

      IF NVL(:NEW.IDTIPCONTAB, '!') <> NVL(:OLD.IDTIPCONTAB, '!')         THEN
         V_DESC := V_DESC || ' TipoContab=' || :NEW.IDTIPCONTAB;
      END IF;

      IF NVL(:NEW.IDPRODNOTA, '!') <> NVL(:OLD.IDPRODNOTA, '!')           THEN
         V_DESC := V_DESC || ' ProdNota=' || :NEW.IDPRODNOTA;
      END IF;

      IF NVL(:NEW.IDTRATIMPO, '!') <> NVL(:OLD.IDTRATIMPO, '!')           THEN
         V_DESC := V_DESC || ' ProdNota=' || :NEW.IDTRATIMPO;
      END IF;

      IF NVL(:NEW.IDUTMUNIORIG, '!') <> NVL(:OLD.IDUTMUNIORIG, '!')       THEN
         V_DESC := V_DESC || ' MuniOrig=' || :NEW.IDUTMUNIORIG;
      END IF;

      IF NVL(:NEW.IDUTUFORIG, '!') <> NVL(:OLD.IDUTUFORIG, '!')           THEN
         V_DESC := V_DESC || ' UFOrig=' || :NEW.IDUTUFORIG;
      END IF;

      IF NVL(:NEW.IDUTUFDEST, '!') <> NVL(:OLD.IDUTUFDEST, '!')           THEN
         V_DESC := V_DESC || ' UFDest=' || :NEW.IDUTUFDEST;
      END IF;

      IF NVL(:NEW.IDUTFAIXVLR, '!') <> NVL(:OLD.IDUTFAIXVLR, '!')         THEN
         V_DESC := V_DESC || ' FaixVr=' || :NEW.IDUTFAIXVLR;
      END IF;

      IF NVL(:NEW.IDUTPARCDED, '!') <> NVL(:OLD.IDUTPARCDED, '!')         THEN
         V_DESC := V_DESC || ' ParcDed=' || :NEW.IDUTPARCDED;
      END IF;

      IF NVL(:NEW.IDUTREDUBC, '!') <> NVL(:OLD.IDUTREDUBC, '!')           THEN
         V_DESC := V_DESC || ' RedBC=' || :NEW.IDUTREDUBC;
      END IF;

      IF NVL(:NEW.IDIMPORECUP, '!') <> NVL(:OLD.IDIMPORECUP, '!')         THEN
         V_DESC := V_DESC || ' ImpoRecup=' || :NEW.IDIMPORECUP;
      END IF;

      IF NVL(:NEW.CDCCTBLDESP, '!') <> NVL(:OLD.CDCCTBLDESP, '!')         THEN
         V_DESC := V_DESC || ' CCtbDesp=' || :NEW.CDCCTBLDESP;
      END IF;

      IF NVL(:NEW.CDCCTBLPASS, '!') <> NVL(:OLD.CDCCTBLPASS, '!')         THEN
         V_DESC := V_DESC || ' CCtbPass=' || :NEW.CDCCTBLPASS;
      END IF;

      IF NVL(:NEW.CDCCTBLATIV, '!') <> NVL(:OLD.CDCCTBLATIV, '!')         THEN
         V_DESC := V_DESC || ' CcAtiv=' || :NEW.CDCCTBLATIV;
      END IF;

      IF NVL(:NEW.CDCCTBLDADM, '!') <> NVL(:OLD.CDCCTBLDADM, '!')         THEN
         V_DESC := V_DESC || 'CCtbADM=' || :NEW.CDCCTBLDADM;
      END IF;

      IF NVL(:NEW.IDCONSISTENT , '!') <> NVL(:OLD.IDCONSISTENT , '!')     THEN
         V_DESC := V_DESC || ' ConsEntr=' || :NEW.IDCONSISTENT ;
      END IF;

      IF NVL(:NEW.IDORGARRECAD, '!') <> NVL(:OLD.IDORGARRECAD, '!')       THEN
         V_DESC := V_DESC || ' OrgArrecad=' || :NEW.IDORGARRECAD;
      END IF;

      IF NVL(:NEW.CDIMPOSAPUR, '!') <> NVL(:OLD.CDIMPOSAPUR, '!')         THEN
         V_DESC := V_DESC || ' ImposApur=' || :NEW.CDIMPOSAPUR;
      END IF;

      IF NVL(:NEW.CDAJUCTREC, '!') <> NVL(:OLD.CDAJUCTREC, '!')           THEN
         V_DESC := V_DESC || ' AjCtReceb=' || :NEW.CDAJUCTREC;
      END IF;

      IF NVL(:NEW.IDDESCRFONTE, '!') <> NVL(:OLD.IDDESCRFONTE, '!')       THEN
         V_DESC := V_DESC || ' DesCRFonte=' || :NEW.IDDESCRFONTE;
      END IF;

      IF NVL(:NEW.IDPREIMPENTR, '!') <> NVL(:OLD.IDPREIMPENTR, '!')       THEN
         V_DESC := V_DESC || ' PreImpEntr=' || :NEW.IDPREIMPENTR;
      END IF;

      IF NVL(:NEW.CDINTIMPOSTO, '!') <> NVL(:OLD.CDINTIMPOSTO, '!')       THEN
         V_DESC := V_DESC || ' IntImposto=' || :NEW.CDINTIMPOSTO;
      END IF;

      IF NVL(:NEW.CDIMPOSTRIB, '!') <> NVL(:OLD.CDIMPOSTRIB, '!')         THEN
         V_DESC := V_DESC || ' ImposTrib=' || :NEW.CDIMPOSTRIB;
      END IF;

      IF NVL(:NEW.CDTPCTPAGAR, '!') <> NVL(:OLD.CDTPCTPAGAR, '!')         THEN
         V_DESC := V_DESC || ' TpCtPagar=' || :NEW.CDTPCTPAGAR;
      END IF;

      IF NVL(:NEW.IDTPIMPOSFIS, '!') <> NVL(:OLD.IDTPIMPOSFIS, '!')       THEN
         V_DESC := V_DESC || ' TpImposFis=' || :NEW.IDTPIMPOSFIS;
      END IF;

      IF NVL(:NEW.IDFORMAPUR, '!') <> NVL(:OLD.IDFORMAPUR, '!')           THEN
         V_DESC := V_DESC || ' FormApur=' || :NEW.IDFORMAPUR;
      END IF;

      IF NVL(:NEW.IDUTALIQTPOPER, '!') <> NVL(:OLD.IDUTALIQTPOPER, '!')   THEN
         V_DESC := V_DESC || ' UtAliqTpOp=' || :NEW.IDUTALIQTPOPER;
      END IF;

      IF NVL(:NEW.CDIMPOSTONFE, '!') <> NVL(:OLD.CDIMPOSTONFE, '!')       THEN
         V_DESC := V_DESC || ' CdImpostoNFE=' || :NEW.CDIMPOSTONFE;
      END IF;

       IF NVL(:NEW.IDDESONERAIMPO, '!') <> NVL(:OLD.IDDESONERAIMPO, '!')  THEN
         V_DESC := V_DESC || ' IdDesoneraImpo=' || :NEW.IDDESONERAIMPO;
      END IF;

       IF NVL(:NEW.IDUTCFOPREGFISC, '!') <> NVL(:OLD.IDUTCFOPREGFISC, '!')THEN
         V_DESC := V_DESC || ' Utiliza CFOP=' || :NEW.IDUTCFOPREGFISC;
      END IF;

       IF NVL(:NEW.IDUTCSTREGFISC, '!') <> NVL(:OLD.IDUTCSTREGFISC, '!')  THEN
         V_DESC := V_DESC || ' Utiliza CST=' || :NEW.IDUTCSTREGFISC;
      END IF;

      IF NVL(:NEW.IDUTVRPAUTA, '!') <> NVL(:OLD.IDUTVRPAUTA, '!')        THEN
         V_DESC := V_DESC || ' UtVrPautaFisc=' || :NEW.IDUTVRPAUTA;
      END IF;

      IF NVL(:NEW.IDUTILPVRIMPBC, '!') <> NVL(:OLD.IDUTILPVRIMPBC, '!')  THEN
         V_DESC := V_DESC || ' UtVrImpBCalc=' || :NEW.IDUTILPVRIMPBC;
      END IF;

      IF NVL(:NEW.VRMAXIMP, -1) <> NVL(:OLD.VRMAXIMP, -1)                THEN
         V_DESC := V_DESC || ' VrMaxImp=' || :NEW.VRMAXIMP;
      END IF;

      IF NVL(:NEW.IDCALCBCMENSDIA, '!') <> NVL(:OLD.IDCALCBCMENSDIA, '!') THEN
         V_DESC := V_DESC || ' IdCalcBCMensDia=' || :NEW.IDCALCBCMENSDIA;
      END IF;

      IF NVL(:NEW.IDPERALIQDIFXML, '!') <> NVL(:OLD.IDPERALIQDIFXML, '!') THEN
         V_DESC := V_DESC || ' IdPerAliqDifXml=' || :NEW.IDPERALIQDIFXML;
      END IF;

      IF NVL(:NEW.DSESTCALCDIFAL, '!') <> NVL(:OLD.DSESTCALCDIFAL, '!') THEN
         V_DESC := V_DESC || ' NCalcDifalLanctoNF=' || :NEW.DSESTCALCDIFAL;
      END IF;

      IF NVL(:NEW.DSESTDIFALDENT, '!') <> NVL(:OLD.DSESTDIFALDENT, '!') THEN
         V_DESC := V_DESC || ' CalcDifalDentroLanctoNF=' || :NEW.DSESTDIFALDENT;
      END IF;

      IF NVL(:NEW.IDGERVRDADOSADIC, '!') <> NVL(:OLD.IDGERVRDADOSADIC, '!') THEN
         V_DESC := V_DESC || ' IdGerVrDadosAdic=' || :NEW.IDGERVRDADOSADIC;
      END IF;

      IF NVL(:NEW.DSVRDADOSADICTPOP, '!') <> NVL(:OLD.DSVRDADOSADICTPOP, '!') THEN
         V_DESC := V_DESC || ' DsVrDadosAdicTpOp=' || :NEW.DSVRDADOSADICTPOP;
      END IF;

   END IF;
   IF V_TIPO <> '0' THEN
      NMUSUARIO(V_USUARIO);
      WEBTUNNING(V_DSREMOTEADDR,
                 V_DSREMOTEHOST,
                 V_DSSERVERRDM,
                 V_DSSERVMETHOD,
                 V_DSREMOTEOPER);
      IF NOT V_DESC IS NULL THEN
         IF NOT V_USUARIO IS NULL THEN
            V_DTOPER := SYSDATE;

            INSERT INTO LOGOPERA
               (NMTABELA,   DTOPERACAO, NMRESPOPER,
                IDTIPOOPER, CDPESQITEM, DSOPERACAO,
                DSRDMUSUOPER, DSENDUSUOPER, DSNMUSUOPER,
                DSMETUSUOPER, CDORESPOPER)
            VALUES
               ('IMPOSTO',  V_DTOPER, V_USUARIO,
                V_TIPO,      V_ITPESQ, SUBSTR(V_DESC, 1, 300),
                V_DSSERVERRDM, V_DSREMOTEADDR,
                V_DSREMOTEHOST, V_DSSERVMETHOD,
                V_DSREMOTEOPER);
         END IF;
      END IF;
   END IF;
END;
/