CREATE OR REPLACE TRIGGER LOG_EST_PARAMGERAL
AFTER DELETE OR INSERT OR UPDATE
ON PARAMGERAL FOR EACH ROW
DECLARE
  V_USUARIO   VARCHAR2(40);
  V_TIPO      VARCHAR2(1);
  V_ITPESQ    VARCHAR2(40);
  V_DESC      VARCHAR2(4000);
  V_DTOPER    DATE;
  V_DSREMOTEADDR VARCHAR2(15);
  V_DSREMOTEHOST VARCHAR2(15);
  V_DSSERVERRDM  VARCHAR2(20);
  V_DSSERVMETHOD VARCHAR2(30);
  V_DSREMOTEOPER VARCHAR2(12);
BEGIN

   V_TIPO := '0';
   V_DESC := '';

   WEBTUNNING(V_DSREMOTEADDR,
              V_DSREMOTEHOST,
              V_DSSERVERRDM,
              V_DSSERVMETHOD,
              V_DSREMOTEOPER);

   IF DELETING THEN
      IF :OLD.DIAINIHORVER IS NOT NULL THEN
         V_DESC := V_DESC || ' DiaInicioHorVerao=' || :OLD.DIAINIHORVER;
      END IF;

      IF :OLD.MESINIHORVER IS NOT NULL THEN
         V_DESC := V_DESC || ' MesInicioHorVerao=' || :OLD.MESINIHORVER;
      END IF;

      IF :OLD.DIAFIMHORVER IS NOT NULL THEN
         V_DESC := V_DESC || ' DiaFimHorVerao=' || :OLD.DIAFIMHORVER;
      END IF;

      IF :OLD.MESFIMHORVER IS NOT NULL THEN
         V_DESC := V_DESC || ' MesFimHorVerao=' || :OLD.MESFIMHORVER;
      END IF;

      IF :OLD.VRPETOLEVRAF IS NOT NULL THEN
         V_DESC := V_DESC || ' PeVrAF=' || :OLD.VRPETOLEVRAF;
      END IF;

      IF :OLD.IDCONSFISCEN IS NOT NULL THEN
         V_DESC := V_DESC || ' IdConF=' || :OLD.IDCONSFISCEN;
      END IF;

      IF :OLD.IDNFOUTRASNF IS NOT NULL THEN
         V_DESC := V_DESC || ' IdNfOut=' || :OLD.IDNFOUTRASNF;
      END IF;

      IF :OLD.IDAVNFNREPEN IS NOT NULL THEN
         V_DESC := V_DESC || ' IdAvNf=' || :OLD.IDAVNFNREPEN;
      END IF;

      IF :OLD.IDCONSVLRMAF IS NOT NULL THEN
         V_DESC := V_DESC || ' ConsQtdMeAF=' || :OLD.IDCONSVLRMAF;
      END IF;

      IF :OLD.IDUTCTRLACES IS NOT NULL THEN
         V_DESC := V_DESC || ' UtilizaCdBarra=' || :OLD.IDUTCTRLACES;
      END IF;
      
      IF SUBSTR(:OLD.DSPARGERFIS,1,1) IS NOT NULL THEN
         V_DESC := V_DESC || ' ObrFornAF=' || SUBSTR(:OLD.DSPARGERFIS,1,1);
      END IF;

      IF SUBSTR(:OLD.DSPARGERFIS,3,3) IS NOT NULL THEN
         V_DESC := V_DESC || ' GrupoFiscal=' || SUBSTR(:OLD.DSPARGERFIS,3,3);
      END IF;

      IF :OLD.VRPETOLEQTAF IS NOT NULL THEN
         V_DESC := V_DESC || ' PeQtAF=' || :OLD.VRPETOLEQTAF;
      END IF;

      IF :OLD.NRDECITOTANF IS NOT NULL THEN
         V_DESC := V_DESC || ' NrDecTotNF=' || :OLD.NRDECITOTANF;
      END IF;

      IF :OLD.VRFAIXTOLENF IS NOT NULL THEN
         V_DESC := V_DESC || ' ToleTotNF=' ||  :OLD.VRFAIXTOLENF;
      END IF;

      IF :OLD.IDBLOQCMPSAF IS NOT NULL THEN
         V_DESC := V_DESC || ' BloqCmpSAF=' || :OLD.IDBLOQCMPSAF;
      END IF;

      IF :OLD.IDTPLANCDESC IS NOT NULL THEN
         V_DESC := V_DESC || ' TpLanDesc=' || :OLD.IDTPLANCDESC;
      END IF;

      IF :OLD.IDGERANFDEVO IS NOT NULL THEN
         V_DESC := V_DESC || ' GeraNFDevo=' || :OLD.IDGERANFDEVO;
      END IF;

      IF :OLD.IDAVNFNOCORR IS NOT NULL THEN
         V_DESC := V_DESC || ' AvOcorrNF=' || :OLD.IDAVNFNOCORR;
      END IF;

      IF :OLD.IDSISDOS IS NOT NULL THEN
         V_DESC := V_DESC || ' SistemaDOS=' || :OLD.IDSISDOS;
      END IF;

      IF :OLD.IDUTSERTPOP IS NOT NULL THEN
         V_DESC := V_DESC || ' SerieTpOperac=' || :OLD.IDUTSERTPOP;
      END IF;

      IF :OLD.IDUTDTPROCTNFE IS NOT NULL THEN
         V_DESC := V_DESC || ' DtProcTransNFE=' || :OLD.IDUTDTPROCTNFE;
      END IF;      
      
      IF :OLD.IDUTILDTPROC IS NOT NULL THEN
         V_DESC := V_DESC || ' DtProc=' || :OLD.IDUTILDTPROC;
      END IF;  
      
      IF :OLD.IDUTCTRLACES IS NOT NULL THEN
         V_DESC := V_DESC || ' UtilCtrlAcesso=' || :OLD.IDUTCTRLACES;
      END IF; 

      IF :OLD.IDUTLBDCENTR IS NOT NULL THEN
         V_DESC := V_DESC || ' UtilBDCentr=' || :OLD.IDUTLBDCENTR;
      END IF;  
      
      IF :OLD.IDUTILGERLOG IS NOT NULL THEN
         V_DESC := V_DESC || ' UtilGrLog=' || :OLD.IDUTILGERLOG;
      END IF; 
      
      IF :OLD.IDPERALTINSFORN IS NOT NULL THEN
         V_DESC := V_DESC || ' PermAltInsForne=' || :OLD.IDPERALTINSFORN;
      END IF; 
      
      IF :OLD.IDUTENDMODFISC IS NOT NULL THEN
         V_DESC := V_DESC || ' UtilEndeModFisc=' || :OLD.IDUTENDMODFISC;
      END IF; 
      
      IF :OLD.IDCACHPRODFI IS NOT NULL THEN
         V_DESC := V_DESC || ' ContCachProdFi=' || :OLD.IDCACHPRODFI;
      END IF;  
      
      IF :OLD.IDRESTRFILIOPER IS NOT NULL THEN
         V_DESC := V_DESC || ' RestVisuFiliOper=' || :OLD.IDRESTRFILIOPER;
      END IF; 
      
      IF :OLD.IDUTCARDPADR IS NOT NULL THEN                                  
         V_DESC := V_DESC || ' UtilCard=' || :OLD.IDUTCARDPADR;
      END IF; 
      
      IF :OLD.IDEXCLANCTB IS NOT NULL THEN
         V_DESC := V_DESC || ' PermAltCradServ=' || :OLD.IDEXCLANCTB;
      END IF;
      
      IF :OLD.CDGROPERPDV1 IS NOT NULL THEN
         V_DESC := V_DESC || ' PermManutComp=' || :OLD.CDGROPERPDV1;
      END IF;  

      IF :OLD.CDGROPERPROP IS NOT NULL THEN
         V_DESC := V_DESC || ' PermManutCdProd=' || :OLD.CDGROPERPROP;
      END IF;
                    
      IF :OLD.VRPECURVAA IS NOT NULL THEN
         V_DESC := V_DESC || ' CurvaA=' || :OLD.VRPECURVAA;
      END IF;

      IF :OLD.VRPECURVAB IS NOT NULL THEN
         V_DESC := V_DESC || ' CurvaB=' || :OLD.VRPECURVAB;
      END IF;
      
      IF :OLD.VRPECURVAC IS NOT NULL THEN
         V_DESC := V_DESC || ' CurvaC=' || :OLD.VRPECURVAC;
      END IF;

      IF :OLD.NRDUPLINFS IS NOT NULL THEN
         V_DESC := V_DESC || ' NrDupliNf=' || :OLD.NRDUPLINFS;
      END IF;

      IF :OLD.IDEMPDESTREPAUT IS NOT NULL THEN
         V_DESC := V_DESC || ' ConsEmprFilDestRepAut=' || :OLD.IDEMPDESTREPAUT;
      END IF;

      IF :OLD.IDUTFILCENTOBR IS NOT NULL THEN
         V_DESC := V_DESC || ' UtFiltroCentObr=' || :OLD.IDUTFILCENTOBR;
      END IF;

      IF :OLD.IDPERLANCNFOUFI IS NOT NULL THEN
         V_DESC := V_DESC || ' PermLancInfNfOutFili=' || :OLD.IDPERLANCNFOUFI;
      END IF;

      IF :OLD.IDREAUDPARFISC IS NOT NULL THEN
         V_DESC := V_DESC || ' RealAudParFis=' || :OLD.IDREAUDPARFISC;
      END IF;

      IF :OLD.IDUTILNFELANCNF IS NOT NULL THEN
         V_DESC := V_DESC || ' UtilizaInfoNFeLancNF=' || :OLD.IDUTILNFELANCNF;
      END IF;

      IF :OLD.IDPERVISIMPSCRE IS NOT NULL THEN
         V_DESC := V_DESC || ' PermiteVisuImpSCre=' || :OLD.IDPERVISIMPSCRE;
      END IF;

      IF :OLD.IDUTCTRLFISENTR IS NOT NULL THEN
         V_DESC := V_DESC || ' ContFiscalEnt=' || :OLD.IDUTCTRLFISENTR;
      END IF;

      IF :OLD.IDUTCTRLFISSAID IS NOT NULL THEN
         V_DESC := V_DESC || ' ContFiscalSai=' || :OLD.IDUTCTRLFISSAID;
      END IF;

      IF :OLD.IDBLOQITNFAPUR IS NOT NULL THEN
         V_DESC := V_DESC || ' IdBloqNfApur=' || :OLD.IDBLOQITNFAPUR;
      END IF;
      
      IF :OLD.IDDTEMISDIFDTBC IS NOT NULL THEN
         V_DESC := V_DESC || ' IdDtEmisDifDtBc=' || :OLD.IDDTEMISDIFDTBC;
      END IF;

      IF :OLD.IDGERNFIGUALXML IS NOT NULL THEN
         V_DESC := V_DESC || ' IdGerNFIgualXML=' || :OLD.IDGERNFIGUALXML;
      END IF;          

      IF :OLD.IDSUGTPOPER IS NOT NULL THEN
         V_DESC := V_DESC || ' SugeTpOperac=' || :OLD.IDSUGTPOPER;
      END IF;

      IF :OLD.CDTPOOPREMESSA IS NOT NULL THEN
         V_DESC := V_DESC || ' TpOpRemessa=' || :OLD.CDTPOOPREMESSA;
      END IF;

      IF :OLD.CDTPOOPRETORNO IS NOT NULL THEN
         V_DESC := V_DESC || ' TpOpRetorno=' || :OLD.CDTPOOPRETORNO;
      END IF;

      IF :OLD.IDCONFISPRTRAENT IS NOT NULL THEN
         V_DESC := V_DESC || ' ConsFiscTraEnt=' || :OLD.IDCONFISPRTRAENT;
      END IF;

      IF :OLD.CDGRSCONSFISCPRE IS NOT NULL THEN
         V_DESC := V_DESC || ' GrupSemConsEnt=' || :OLD.CDGRSCONSFISCPRE;
      END IF;

      IF :OLD.IDCONFISPRTRASAI IS NOT NULL THEN
         V_DESC := V_DESC || ' ConsFiscTraSai=' || :OLD.IDCONFISPRTRASAI;
      END IF;

      IF :OLD.CDGRSCONSFISCPRS IS NOT NULL THEN
         V_DESC := V_DESC || ' GrupSemConsSai=' || :OLD.CDGRSCONSFISCPRS;
      END IF;

      IF :OLD.IDCONFISPRFORENT IS NOT NULL THEN
         V_DESC := V_DESC || '  ConsFiscFornEnt=' || :OLD.IDCONFISPRFORENT;
      END IF;

      IF :OLD.IDCONFISPRFILENT IS NOT NULL THEN
         V_DESC := V_DESC || '  ConsFiscFilEnt=' || :OLD.IDCONFISPRFILENT;
      END IF;

      IF :OLD.IDCONFISPRCLSAID IS NOT NULL THEN
         V_DESC := V_DESC || '  ConsFiscCliSai=' || :OLD.IDCONFISPRCLSAID;
      END IF;

      IF :OLD.IDCONFISPRFILSAI IS NOT NULL THEN
         V_DESC := V_DESC || '  ConsFiscFilSai=' || :OLD.IDCONFISPRFILSAI;
      END IF;

      IF :OLD.IDPERMALTNFPED IS NOT NULL THEN
         V_DESC := V_DESC || '  PermAlterNFPedido=' || :OLD.IDPERMALTNFPED;
      END IF;

      IF :OLD.IDOBTPOPLANCSIMP IS NOT NULL THEN
         V_DESC := V_DESC || '  ObrigTpOpLancSimp=' || :OLD.IDOBTPOPLANCSIMP;
      END IF;

      IF :OLD.IDBAIXAFTOTLANNF IS NOT NULL THEN
         V_DESC := V_DESC || ' BaixAFTot=' || :OLD.IDBAIXAFTOTLANNF;
      END IF;

      IF :OLD.IDOPPRESENDDIF IS NOT NULL THEN
         V_DESC := V_DESC || ' Presencial_DestDif=' || :OLD.IDOPPRESENDDIF;
      END IF;

      IF :OLD.IDPERLANESTAPNF IS NOT NULL THEN
         V_DESC := V_DESC || ' IdGerEstoqAprov=' || :OLD.IDPERLANESTAPNF;
      END IF;

      IF :OLD.IDADICVENDEDOR IS NOT NULL THEN
         V_DESC := V_DESC || ' IdGravaVendDadoAdicNF=' || :OLD.IDADICVENDEDOR;
      END IF;
	  
      IF :OLD.IDADICNRPEDIDO IS NOT NULL THEN
         V_DESC := V_DESC || ' IdGravaPedDadoAdicNF=' || :OLD.IDADICNRPEDIDO;
      END IF;	  

      V_TIPO := '3';
      V_ITPESQ := :OLD.CDPARGERAL;
   ELSE
      IF UPDATING THEN
         IF (NVL(:OLD.DIAINIHORVER,0)              <> NVL(:NEW.DIAINIHORVER,0))              OR
            (NVL(:OLD.MESINIHORVER,0)              <> NVL(:NEW.MESINIHORVER,0))              OR
            (NVL(:OLD.DIAFIMHORVER,0)              <> NVL(:NEW.DIAFIMHORVER,0))              OR
            (NVL(:OLD.MESFIMHORVER,0)              <> NVL(:NEW.MESFIMHORVER,0))              OR
            (NVL(:OLD.VRPETOLEVRAF,0)              <> NVL(:NEW.VRPETOLEVRAF,0))              OR
            (NVL(:OLD.VRPETOLEQTAF,0)              <> NVL(:NEW.VRPETOLEQTAF,0))              OR
            (NVL(:OLD.NRDECITOTANF,0)              <> NVL(:NEW.NRDECITOTANF,0))              OR
            (NVL(:OLD.VRFAIXTOLENF,0)              <> NVL(:NEW.VRFAIXTOLENF,0))              OR
            (NVL(:OLD.VRPECURVAA,0)                <> NVL(:NEW.VRPECURVAA,0))                OR
            (NVL(:OLD.VRPECURVAB,0)                <> NVL(:NEW.VRPECURVAB,0))                OR
            (NVL(:OLD.VRPECURVAC,0)                <> NVL(:NEW.VRPECURVAC,0))                OR
            (NVL(:OLD.IDBLOQCMPSAF,'!')            <> NVL(:NEW.IDBLOQCMPSAF,'!'))            OR
            (NVL(:OLD.IDTPLANCDESC,'!')            <> NVL(:NEW.IDTPLANCDESC,'!'))            OR
            (NVL(:OLD.IDGERANFDEVO,'!')            <> NVL(:NEW.IDGERANFDEVO,'!'))            OR
            (NVL(:OLD.IDAVNFNOCORR,'!')            <> NVL(:NEW.IDAVNFNOCORR,'!'))            OR
            (NVL(:OLD.IDNFOUTRASNF,'!')            <> NVL(:NEW.IDNFOUTRASNF,'!'))            OR
            (NVL(:OLD.IDAVNFNREPEN,'!')            <> NVL(:NEW.IDAVNFNREPEN,'!'))            OR
            (NVL(:OLD.IDSISDOS,'!')                <> NVL(:NEW.IDSISDOS,'!'))                OR
            (NVL(:OLD.IDUTDTPROCTNFE,'!')          <> NVL(:NEW.IDUTDTPROCTNFE,'!'))          OR
            (NVL(:OLD.IDUTSERTPOP,'!')             <> NVL(:NEW.IDUTSERTPOP,'!'))             OR
            (NVL(:OLD.IDUTCODBARRA,'!')            <> NVL(:NEW.IDUTCODBARRA,'!'))            OR
            (NVL(:OLD.IDUTILDTPROC,'!')            <> NVL(:NEW.IDUTILDTPROC,'!'))            OR
            (NVL(:OLD.IDUTCTRLACES,'!')            <> NVL(:NEW.IDUTCTRLACES,'!'))            OR
            (NVL(:OLD.IDUTLBDCENTR,'!')            <> NVL(:NEW.IDUTLBDCENTR,'!'))            OR
            (NVL(:OLD.IDUTILGERLOG,'!')            <> NVL(:NEW.IDUTILGERLOG,'!'))            OR
            (NVL(:OLD.IDPERALTINSFORN,'!')         <> NVL(:NEW.IDPERALTINSFORN,'!'))         OR
            (NVL(:OLD.IDUTENDMODFISC,'!')          <> NVL(:NEW.IDUTENDMODFISC,'!'))          OR
            (NVL(:OLD.IDCACHPRODFI,'!')            <> NVL(:NEW.IDCACHPRODFI,'!'))            OR
            (NVL(:OLD.IDRESTRFILIOPER,'!')         <> NVL(:NEW.IDRESTRFILIOPER,'!'))         OR
            (NVL(:OLD.IDUTCARDPADR,'!')            <> NVL(:NEW.IDUTCARDPADR,'!'))            OR
            (NVL(:OLD.IDEXCLANCTB,'!')             <> NVL(:NEW.IDEXCLANCTB,'!'))             OR
            (NVL(:OLD.CDGROPERPDV1,'!')            <> NVL(:NEW.CDGROPERPDV1,'!'))            OR
            (NVL(:OLD.CDGROPERPROP,'!')            <> NVL(:NEW.CDGROPERPROP,'!'))            OR
            (NVL(SUBSTR(:OLD.DSPARGERFIS,1,1),'!') <> NVL(SUBSTR(:NEW.DSPARGERFIS,1,1),'!')) OR
            (NVL(SUBSTR(:OLD.DSPARGERFIS,3,3),'!') <> NVL(SUBSTR(:NEW.DSPARGERFIS,3,3),'!')) OR
            (NVL(:OLD.NRDUPLINFS, '!')             <> NVL(:NEW.NRDUPLINFS, '!'))             OR
            (NVL(:OLD.IDEMPDESTREPAUT, '!')        <> NVL(:NEW.IDEMPDESTREPAUT, '!'))        OR
            (NVL(:OLD.IDUTFILCENTOBR, '!')         <> NVL(:NEW.IDUTFILCENTOBR, '!'))         OR
            (NVL(:OLD.IDPERLANCNFOUFI, '!')        <> NVL(:NEW.IDPERLANCNFOUFI, '!'))        OR
            (NVL(:OLD.IDREAUDPARFISC, '!')         <> NVL(:NEW.IDREAUDPARFISC, '!'))         OR
            (NVL(:OLD.IDUTILNFELANCNF, '!')        <> NVL(:NEW.IDUTILNFELANCNF, '!'))        OR
            (NVL(:OLD.IDPERVISIMPSCRE, '!')        <> NVL(:NEW.IDPERVISIMPSCRE, '!'))        OR
            (NVL(:OLD.IDUTCTRLFISENTR,'!')         <> NVL(:NEW.IDUTCTRLFISENTR,'!'))         OR
            (NVL(:OLD.IDUTCTRLFISSAID,'!')         <> NVL(:NEW.IDUTCTRLFISSAID,'!'))         OR
            (NVL(:OLD.IDBLOQITNFAPUR,'!')          <> NVL(:NEW.IDBLOQITNFAPUR,'!'))          OR
            (NVL(:OLD.IDDTEMISDIFDTBC,'!')         <> NVL(:NEW.IDDTEMISDIFDTBC,'!'))         OR
            (NVL(:OLD.IDGERNFIGUALXML,'!')         <> NVL(:NEW.IDGERNFIGUALXML,'!'))         OR
            (NVL(:OLD.IDPERAPROVNFXML,'!')         <> NVL(:NEW.IDPERAPROVNFXML,'!'))         OR
            (NVL(:OLD.CDTPOOPREMESSA,'!')          <> NVL(:NEW.CDTPOOPREMESSA,'!'))          OR
            (NVL(:OLD.CDTPOOPRETORNO,'!')          <> NVL(:NEW.CDTPOOPRETORNO,'!'))          OR
            (NVL(:OLD.IDCONFISPRTRAENT,'!')        <> NVL(:NEW.IDCONFISPRTRAENT,'!'))        OR
            (NVL(:OLD.CDGRSCONSFISCPRE,'!')        <> NVL(:NEW.CDGRSCONSFISCPRE,'!'))        OR
            (NVL(:OLD.IDCONFISPRTRASAI,'!')        <> NVL(:NEW.IDCONFISPRTRASAI,'!'))        OR
            (NVL(:OLD.CDGRSCONSFISCPRS,'!')        <> NVL(:NEW.CDGRSCONSFISCPRS,'!'))        OR
            (NVL(:OLD.IDCONFISPRFORENT,'!')        <> NVL(:NEW.IDCONFISPRFORENT,'!'))        OR
            (NVL(:OLD.IDCONFISPRFILENT,'!')        <> NVL(:NEW.IDCONFISPRFILENT,'!'))        OR
            (NVL(:OLD.IDCONFISPRCLSAID,'!')        <> NVL(:NEW.IDCONFISPRCLSAID,'!'))        OR
            (NVL(:OLD.IDCONFISPRFILSAI,'!')        <> NVL(:NEW.IDCONFISPRFILSAI,'!'))        OR
            (NVL(:OLD.IDPERMALTNFPED,'!')          <> NVL(:NEW.IDPERMALTNFPED,'!'))          OR
            (NVL(:OLD.IDOBTPOPLANCSIMP,'!')        <> NVL(:NEW.IDOBTPOPLANCSIMP,'!'))        OR
            (NVL(:OLD.IDBAIXAFTOTLANNF,'!')        <> NVL(:NEW.IDBAIXAFTOTLANNF,'!'))        OR
            (NVL(:OLD.IDOPPRESENDDIF,'!')          <> NVL(:NEW.IDOPPRESENDDIF,'!'))          OR
            (NVL(:OLD.IDPERLANESTAPNF,'!')         <> NVL(:NEW.IDPERLANESTAPNF,'!'))         OR           
            (NVL(:OLD.IDSUGTPOPER,'!')             <> NVL(:NEW.IDSUGTPOPER,'!'))             OR
            (NVL(:OLD.IDADICVENDEDOR,'!')          <> NVL(:NEW.IDADICVENDEDOR,'!'))          OR			
			(NVL(:OLD.IDADICNRPEDIDO,'!') 		   <> NVL(:NEW.IDADICNRPEDIDO,'!'))          THEN

            V_TIPO   := '2';
            V_ITPESQ := :OLD.CDPARGERAL;
         END IF;
      ELSE
         V_TIPO   := '1';
         V_ITPESQ := :NEW.CDPARGERAL;
      END IF;

      IF NVL(:OLD.DIAINIHORVER, 0) <>  NVL(:NEW.DIAINIHORVER, 0) THEN
         V_DESC := V_DESC || ' DiaInicioHorVerao=' || :NEW.DIAINIHORVER;
      END IF;

      IF NVL(:OLD.MESINIHORVER, 0) <>  NVL(:NEW.MESINIHORVER, 0) THEN
         V_DESC := V_DESC || ' MesInicioHorVerao=' || :NEW.MESINIHORVER;
      END IF;

      IF NVL(:OLD.DIAFIMHORVER, 0) <>  NVL(:NEW.DIAFIMHORVER, 0) THEN
         V_DESC := V_DESC || ' DiaFimHorVerao=' || :NEW.DIAFIMHORVER;
      END IF;

      IF NVL(:OLD.MESFIMHORVER, 0) <>  NVL(:NEW.MESFIMHORVER, 0) THEN
         V_DESC := V_DESC || ' MesFimHorVerao=' || :NEW.MESFIMHORVER;
      END IF;

      IF NVL(:OLD.IDCONSFISCEN,'') <>  NVL(:NEW.IDCONSFISCEN,'') THEN
         V_DESC := V_DESC || ' IdConF=' || :NEW.IDCONSFISCEN;
      END IF;

      IF NVL(:OLD.IDNFOUTRASNF,'') <>  NVL(:NEW.IDNFOUTRASNF,'') THEN
         V_DESC := V_DESC || ' IdNfOut=' || :NEW.IDNFOUTRASNF;
      END IF;

      IF NVL(:OLD.IDAVNFNREPEN,'') <>  NVL(:NEW.IDAVNFNREPEN,'') THEN
         V_DESC := V_DESC || ' IdAvNf=' || :NEW.IDAVNFNREPEN;
      END IF;

      IF NVL(SUBSTR(:OLD.DSPARGERFIS,1,1),'!') <> NVL(SUBSTR(:NEW.DSPARGERFIS,1,1),'!') THEN
         V_DESC := V_DESC || ' ObrFornAF=' || SUBSTR(:NEW.DSPARGERFIS,1,1);
      END IF;

      IF NVL(SUBSTR(:OLD.DSPARGERFIS,3,3),'!') <> NVL(SUBSTR(:NEW.DSPARGERFIS,3,3),'!')  THEN
         V_DESC := V_DESC || ' GrupoFiscal=' || SUBSTR(:NEW.DSPARGERFIS,3,3);
      END IF;

      IF NVL(:OLD.IDCONSVLRMAF, '') <> NVL(:NEW.IDCONSVLRMAF, '') THEN
         V_DESC := V_DESC || ' ConsQtdMeAF=' || :NEW.IDCONSVLRMAF;
      END IF;

      IF NVL(:OLD.IDUTCODBARRA, '') <> NVL(:NEW.IDUTCODBARRA, '') THEN
         V_DESC := V_DESC || ' UtilizaCdBarra=' || :NEW.IDUTCODBARRA;
      END IF;

      IF NVL(:OLD.VRPETOLEVRAF, 0) <> NVL(:NEW.VRPETOLEVRAF, 0) THEN
         V_DESC := V_DESC || ' PeVrAF=' || :NEW.VRPETOLEVRAF;
      END IF;

      IF NVL(:OLD.VRPETOLEQTAF,0) <> NVL(:NEW.VRPETOLEQTAF,0) THEN
         V_DESC := V_DESC || ' PeQtAF=' || :NEW.VRPETOLEQTAF;
      END IF;

      IF NVL(:OLD.NRDECITOTANF, 0) <> NVL(:NEW.NRDECITOTANF, 0) THEN
         V_DESC := V_DESC || ' NrDecTotNF=' || :NEW.NRDECITOTANF;
      END IF;

      IF NVL(:OLD.VRFAIXTOLENF, 0) <> NVL(:NEW.VRFAIXTOLENF, 0) THEN
         V_DESC := V_DESC || ' ToleTotNF=' ||  :NEW.VRFAIXTOLENF;
      END IF;

      IF NVL(:OLD.VRPECURVAA, 0) <> NVL(:NEW.VRPECURVAA, 0) THEN
         V_DESC := V_DESC || ' CurvaA=' || :NEW.VRPECURVAA;
      END IF;

      IF NVL(:OLD.VRPECURVAB, 0) <> NVL(:NEW.VRPECURVAB, 0) THEN
         V_DESC := V_DESC || ' CurvaB=' || :NEW.VRPECURVAB;
      END IF;

      IF NVL(:OLD.VRPECURVAC, 0) <> NVL(:NEW.VRPECURVAC, 0) THEN
         V_DESC := V_DESC || ' CurvaC=' || :NEW.VRPECURVAC;
      END IF;

      IF NVL(:OLD.IDBLOQCMPSAF, '') <> NVL(:NEW.IDBLOQCMPSAF, '') THEN
         V_DESC := V_DESC || ' BloqCmpSAF=' || :NEW.IDBLOQCMPSAF;
      END IF;

      IF NVL(:OLD.IDTPLANCDESC, '') <> NVL(:NEW.IDTPLANCDESC, '') THEN
         V_DESC := V_DESC || ' TpLanDesc=' || :NEW.IDTPLANCDESC;
      END IF;

      IF NVL(:OLD.IDGERANFDEVO, '') <> NVL(:NEW.IDGERANFDEVO, '') THEN
         V_DESC := V_DESC || ' GeraNFDevo=' || :NEW.IDGERANFDEVO;
      END IF;

      IF NVL(:OLD.IDAVNFNOCORR, '') <> NVL(:NEW.IDAVNFNOCORR, '') THEN
         V_DESC := V_DESC || ' AvOcorrNF=' || :NEW.IDAVNFNOCORR;
      END IF;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      IF NVL(:OLD.IDUTCTRLFISSAID,'!') <> NVL(:NEW.IDUTCTRLFISSAID,'!') THEN
         V_DESC := V_DESC || ' ContFiscalSai=' || :NEW.IDUTCTRLFISSAID;
      END IF;
      
      IF NVL(:OLD.IDBLOQITNFAPUR,'!') <> NVL(:NEW.IDBLOQITNFAPUR,'!') THEN
         V_DESC := V_DESC || ' IdBloqNfApur=' || :NEW.IDBLOQITNFAPUR;
      END IF;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      IF NVL(:OLD.IDADICVENDEDOR,'!') <> NVL(:NEW.IDADICVENDEDOR,'!') THEN
         V_DESC := V_DESC || ' IdGravaVendDadoAdicNF=' || :NEW.IDADICVENDEDOR;
      END IF;
	  
      IF NVL(:OLD.IDADICNRPEDIDO,'!') <> NVL(:NEW.IDADICNRPEDIDO,'!')THEN
         V_DESC := V_DESC || ' IdGravaPedDadoAdicNF=' || :NEW.IDADICNRPEDIDO;
      END IF;		  

   END IF;
   IF V_TIPO <> '0' THEN
      IF NOT V_DESC IS NULL THEN
         NMUSUARIO(V_USUARIO);
         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
               ('PARAMGERAL',  V_DTOPER, V_USUARIO,
                V_TIPO,         V_ITPESQ, SUBSTR(V_DESC, 0, 400),V_DSREMOTEADDR, V_DSREMOTEHOST, V_DSSERVERRDM,
                V_DSSERVMETHOD, V_DSREMOTEOPER);
         END IF;
      END IF;
   END IF;
END;
/