CREATE OR REPLACE TRIGGER LOG_CDP_PARAMAN
AFTER DELETE OR INSERT OR UPDATE
ON PARAMAN 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_DESC         VARCHAR2(4000);
  V_ITPESQ       VARCHAR2(80); 
  V_NMOPERADOR   VARCHAR2(40);
  V_IDTIPOOPER   VARCHAR2(1);
  V_CDFILLOGOPER VARCHAR2(4);
  V_TAM          INTEGER;
BEGIN
/* IDTIPOOPER - '1' - Inclusao, '2' - Alteracao, '3' - Exclusao*/

   V_DESC       := '';
   V_ITPESQ     := '';
   V_NMOPERADOR := '';
   V_IDTIPOOPER := '';
   V_CDFILLOGOPER := '';
   
   NMUSUARIO(V_NMOPERADOR);
   WEBTUNNING(V_DSREMOTEADDR,
              V_DSREMOTEHOST,
              V_DSSERVERRDM,
              V_DSSERVMETHOD,
              V_DSREMOTEOPER);

   IF INSERTING THEN

      IF :NEW.CDFILIAL IS NOT NULL THEN
         V_DESC := V_DESC || 'CdFilial= ' || NVL(:NEW.CDFILIAL,'') || ' ' ;
      END IF;

      IF :NEW.CDPARAMAN IS NOT NULL THEN
         V_DESC := V_DESC || 'CdParaman= ' || NVL(:NEW.CDPARAMAN,'') || ' ' ;
      END IF;

      IF :NEW.IDATUESTOQ IS NOT NULL THEN
         V_DESC := V_DESC || 'IdAtuEstoq= ' || NVL(:NEW.IDATUESTOQ,'') || ' ' ;
      END IF;

      IF :NEW.DSNUMELOTEPR IS NOT NULL THEN
         V_DESC := V_DESC || 'DsNumeLotePr= ' || NVL(:NEW.DSNUMELOTEPR,'') || ' ' ;
      END IF;

      IF :NEW.DSSEQULOTEPR IS NOT NULL THEN
         V_DESC := V_DESC || 'DsSequLotePr= ' || NVL(:NEW.DSSEQULOTEPR,'') || ' ' ;
      END IF;

      IF :NEW.CDSETORPROD IS NOT NULL THEN
         V_DESC := V_DESC || 'CdSetorProd= ' || NVL(:NEW.CDSETORPROD,'') || ' ' ;
      END IF;

      IF :NEW.IDUTILIZLOTE IS NOT NULL THEN
         V_DESC := V_DESC || 'IDUTILIZLOTE= ' || NVL(:NEW.IDUTILIZLOTE,'') || ' ' ;
      END IF;

      IF :NEW.QTHRPADRPROD IS NOT NULL THEN
         V_DESC := V_DESC || 'QtHrPadrProd= ' || NVL(:NEW.QTHRPADRPROD,'') || ' ' ;
      END IF;

      IF :NEW.NRTPCUSTOOP IS NOT NULL THEN
         V_DESC := V_DESC || 'NrTpCustoOp= ' || NVL(:NEW.NRTPCUSTOOP,'') || ' ' ;
      END IF;

      IF :NEW.CDTIPORETI IS NOT NULL THEN
         V_DESC := V_DESC || 'CdTipoReti= ' || NVL(:NEW.CDTIPORETI,'') || ' ' ;
      END IF;

      IF :NEW.CDRETIRESE IS NOT NULL THEN
         V_DESC := V_DESC || 'CdRetiRese= ' || NVL(:NEW.CDRETIRESE,'') || ' ' ;
      END IF;

      IF :NEW.IDGEPERDAREN IS NOT NULL THEN
         V_DESC := V_DESC || 'IdGePerdaRen= ' || NVL(:NEW.IDGEPERDAREN,'') || ' ' ;
      END IF;

      IF :NEW.DTULTATUPMAN IS NOT NULL THEN
         V_DESC := V_DESC || 'DtUltAtuPMan= ' || NVL(:NEW.DTULTATUPMAN,'') || ' ' ;
      END IF;

      IF :NEW.IDSUBOPSEMIACA IS NOT NULL THEN
         V_DESC := V_DESC || 'IdSubOpSemiAca= ' || NVL(:NEW.IDSUBOPSEMIACA,'') || ' ' ;
      END IF;

      IF :NEW.IDBLPRANAINIOP IS NOT NULL THEN
         V_DESC := V_DESC || 'IDBlPranaIniOp= ' || NVL(:NEW.IDBLPRANAINIOP,'') || ' ' ;
      END IF;

      IF :NEW.IDUTSEGLIBLOTE IS NOT NULL THEN
         V_DESC := V_DESC || 'IdUtSegLibLote= ' || NVL(:NEW.IDUTSEGLIBLOTE,'') || ' ' ;
      END IF;

      IF :NEW.IDRESLOTEPEDPLA IS NOT NULL THEN
         V_DESC := V_DESC || 'IdResLotePedPla= ' || NVL(:NEW.IDRESLOTEPEDPLA,'') || ' ' ;
      END IF;

      IF :NEW.IDUTEQUIPLAPROD IS NOT NULL THEN
         V_DESC := V_DESC || 'IdUtEquiPlaProd= ' || NVL(:NEW.IDUTEQUIPLAPROD,'') || ' ' ;
      END IF;

      IF :NEW.IDUTLOCESTPRACA IS NOT NULL THEN
         V_DESC := V_DESC || 'IdUtLocEstPrAca= ' || NVL(:NEW.IDUTLOCESTPRACA,'') || ' ' ;
      END IF;

      IF :NEW.IDVALANARETPROD IS NOT NULL THEN
         V_DESC := V_DESC || 'IdValAnaRetProd= ' || NVL(:NEW.IDVALANARETPROD,'') || ' ' ;
      END IF;

      IF :NEW.IDTPCALCCUSPROD IS NOT NULL THEN
         V_DESC := V_DESC || 'IdTpCalcCusProd= ' || NVL(:NEW.IDTPCALCCUSPROD,'') || ' ' ;
      END IF;

      IF :NEW.IDUTAPPCC IS NOT NULL THEN
         V_DESC := V_DESC || 'IDUTAPPCC= ' || NVL(:NEW.IDUTAPPCC,'') || ' ' ;
      END IF;

      IF :NEW.IDVALINSPRETPRO IS NOT NULL THEN
         V_DESC := V_DESC || 'IdValInspRetPro= ' || NVL(:NEW.IDVALINSPRETPRO,'') || ' ' ;
      END IF;

      IF :NEW.IDPRIORIPROD IS NOT NULL THEN
         V_DESC := V_DESC || 'IdPrioriProd= ' || NVL(:NEW.IDPRIORIPROD,'') || ' ' ;
      END IF;

      IF :NEW.NRRETMAXLOT IS NOT NULL THEN
         V_DESC := V_DESC || 'NrRetMaxLot= ' || NVL(:NEW.NRRETMAXLOT,'') || ' ' ;
      END IF;

      IF :NEW.IDALTERAPCPRET IS NOT NULL THEN
         V_DESC := V_DESC || 'IdAlteraPcpRet= ' || NVL(:NEW.IDALTERAPCPRET,'') || ' ' ;
      END IF;

      IF :NEW.IDLOTEPROD IS NOT NULL THEN
         V_DESC := V_DESC || 'IdLoteProd= ' || NVL(:NEW.IDLOTEPROD,'') || ' ' ;
      END IF;

      IF :NEW.IDAUDIPROCFAB IS NOT NULL THEN
         V_DESC := V_DESC || 'IdAudiProcFab= ' || NVL(:NEW.IDAUDIPROCFAB,'') || ' ' ;
      END IF;

      IF :NEW.IDUTAUTSENHA IS NOT NULL THEN
         V_DESC := V_DESC || 'IdUtAutSenha= ' || NVL(:NEW.IDUTAUTSENHA,'') || ' ' ;
      END IF;

      IF :NEW.IDGERAOPPEDIDO IS NOT NULL THEN
         V_DESC := V_DESC || 'IdGeraOpPedido= ' || NVL(:NEW.IDGERAOPPEDIDO,'') || ' ' ;
      END IF;

      IF :NEW.IDUTAUTSENHARET IS NOT NULL THEN
         V_DESC := V_DESC || 'IdUtAutSenhaRet= ' || NVL(:NEW.IDUTAUTSENHARET,'') || ' ' ;
      END IF;

      IF :NEW.IDTPRETIRADA IS NOT NULL THEN
         V_DESC := V_DESC || 'IdTpRetirada= ' || NVL(:NEW.IDTPRETIRADA,'') || ' ' ;
      END IF;

      IF :NEW.IDALTERARETI IS NOT NULL THEN
         V_DESC := V_DESC || 'IdAlteraReti= ' || NVL(:NEW.IDALTERARETI,'') || ' ' ;
      END IF;

      IF :NEW.IDVDSEMIVDACAB IS NOT NULL THEN
         V_DESC := V_DESC || 'IdVdSemiVdAcab= ' || NVL(:NEW.IDVDSEMIVDACAB,'') || ' ' ;
      END IF;

      IF :NEW.CDFORNECEDBANH IS NOT NULL THEN
         V_DESC := V_DESC || 'CdFornecedBanh= ' || NVL(:NEW.CDFORNECEDBANH,'') || ' ' ;
      END IF;

      IF :NEW.VRSERVICO IS NOT NULL THEN
         V_DESC := V_DESC || 'VrServico= ' || NVL(:NEW.VRSERVICO,'') || ' ' ;
      END IF;

      IF :NEW.VRPROPORCAO IS NOT NULL THEN
         V_DESC := V_DESC || 'VrProporcao= ' || NVL(:NEW.VRPROPORCAO,'') || ' ' ;
      END IF;

      IF :NEW.IDLOTEPRODCOMP IS NOT NULL THEN
         V_DESC := V_DESC || 'IdLoteProdComp= ' || NVL(:NEW.IDLOTEPRODCOMP,'') || ' ' ;
      END IF;

      IF :NEW.IDRETPERDAUTO IS NOT NULL THEN
         V_DESC := V_DESC || 'IdRetPerdAuto= ' || NVL(:NEW.IDRETPERDAUTO,'') || ' ' ;
      END IF;

      IF :NEW.IDLIBLOTEEST IS NOT NULL THEN
         V_DESC := V_DESC || 'IdLibLoteEst= ' || NVL(:NEW.IDLIBLOTEEST,'') || ' ' ;
      END IF;

      IF :NEW.IDALTERAFECHA IS NOT NULL THEN
         V_DESC := V_DESC || 'IdAlteraFecha= ' || NVL(:NEW.IDALTERAFECHA,'') || ' ' ;
      END IF;

      IF :NEW.IDRECALCQTOP IS NOT NULL THEN
         V_DESC := V_DESC || 'IdRecalcQtOp= ' || NVL(:NEW.IDRECALCQTOP,'') || ' ' ;
      END IF;

      IF :NEW.IDUNIDADEVRINT IS NOT NULL THEN
         V_DESC := V_DESC || 'IdUnidadeVrInt= ' || NVL(:NEW.IDUNIDADEVRINT,'') || ' ' ;
      END IF;

      IF :NEW.DSUNIDMEDIDA IS NOT NULL THEN
         V_DESC := V_DESC || 'DsUnidMedida= ' || NVL(:NEW.DSUNIDMEDIDA,'') || ' ' ;
      END IF;

      IF :NEW.CDPRODAGUA IS NOT NULL THEN
         V_DESC := V_DESC || 'CDPRODAGUA= ' || NVL(:NEW.CDPRODAGUA,'') || ' ' ;
      END IF;

      IF :NEW.VRPRODAGUA IS NOT NULL THEN
         V_DESC := V_DESC || 'VRPRODAGUA= ' || NVL(:NEW.VRPRODAGUA,'') || ' ' ;
      END IF;

      IF :NEW.VRULTPRODAGUA IS NOT NULL THEN
         V_DESC := V_DESC || 'VRULTPRODAGUA= ' || NVL(:NEW.VRULTPRODAGUA,'') || ' ' ;
      END IF;

      IF :NEW.IDBLOQFECHA IS NOT NULL THEN
         V_DESC := V_DESC || 'IDBLOQFECHA= ' || NVL(:NEW.IDBLOQFECHA,'') || ' ' ;
      END IF;

      IF :NEW.IDVRUNITPRACAB IS NOT NULL THEN
         V_DESC := V_DESC || 'CalcVrUnitQtReal= ' || NVL(:NEW.IDVRUNITPRACAB,'') || ' ' ;
      END IF;

      IF :NEW.IDUTBALCWTFECHOP IS NOT NULL THEN
         V_DESC := V_DESC || 'IDUTBALCWTFECHOP= ' || NVL(:NEW.IDUTBALCWTFECHOP,'') || ' ' ;
      END IF;

      IF :NEW.IDMODELOBALANCA IS NOT NULL THEN
         V_DESC := V_DESC || 'IDMODELOBALANCA= ' || NVL(:NEW.IDMODELOBALANCA,'') || ' ' ;
      END IF;

      IF :NEW.IDTIPOCONEXAO IS NOT NULL THEN
         V_DESC := V_DESC || 'IDTIPOCONEXAO= ' || NVL(:NEW.IDTIPOCONEXAO,'') || ' ' ;
      END IF;

      IF :NEW.DSIPBALANCA IS NOT NULL THEN
         V_DESC := V_DESC || 'DSIPBALANCA= ' || NVL(:NEW.DSIPBALANCA,'') || ' ' ;
      END IF;

      IF :NEW.CDPORTABALANCA IS NOT NULL THEN
         V_DESC := V_DESC || 'CDPORTABALANCA= ' || NVL(:NEW.CDPORTABALANCA,'') || ' ' ;
      END IF;

      IF :NEW.IDINFPESOMANUAL IS NOT NULL THEN
         V_DESC := V_DESC || 'IDINFPESOMANUAL= ' || NVL(:NEW.IDINFPESOMANUAL,'') || ' ' ;
      END IF;

      V_ITPESQ := :NEW.CDFILIAL   || :NEW.CDPARAMAN;

      V_IDTIPOOPER := '1';

   END IF;

   IF UPDATING THEN

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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





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





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

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

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

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

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

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

      V_ITPESQ := :NEW.CDFILIAL   || :NEW.CDPARAMAN;

      V_IDTIPOOPER := '2';

   END IF;

   IF DELETING  THEN

      IF :OLD.CDFILIAL IS NOT NULL THEN
         V_DESC := V_DESC || 'CdFilial= ' || NVL(:OLD.CDFILIAL,'') || ' ' ;
      END IF;

      IF :OLD.CDPARAMAN IS NOT NULL THEN
         V_DESC := V_DESC || 'CdParaman= ' || NVL(:OLD.CDPARAMAN,'') || ' ' ;
      END IF;

      IF :OLD.IDATUESTOQ IS NOT NULL THEN
         V_DESC := V_DESC || 'IdAtuEstoq= ' || NVL(:OLD.IDATUESTOQ,'') || ' ' ;
      END IF;

      IF :OLD.DSNUMELOTEPR IS NOT NULL THEN
         V_DESC := V_DESC || 'DsNumeLotePr= ' || NVL(:OLD.DSNUMELOTEPR,'') || ' ' ;
      END IF;

      IF :OLD.DSSEQULOTEPR IS NOT NULL THEN
         V_DESC := V_DESC || 'DsSequLotePr= ' || NVL(:OLD.DSSEQULOTEPR,'') || ' ' ;
      END IF;

      IF :OLD.CDSETORPROD IS NOT NULL THEN
         V_DESC := V_DESC || 'CdSetorProd= ' || NVL(:OLD.CDSETORPROD,'') || ' ' ;
      END IF;

      IF :OLD.IDUTILIZLOTE IS NOT NULL THEN
         V_DESC := V_DESC || 'IDUTILIZLOTE= ' || NVL(:OLD.IDUTILIZLOTE,'') || ' ' ;
      END IF;

      IF :OLD.QTHRPADRPROD IS NOT NULL THEN
         V_DESC := V_DESC || 'QtHrPadrProd= ' || NVL(:OLD.QTHRPADRPROD,'') || ' ' ;
      END IF;

      IF :OLD.NRTPCUSTOOP IS NOT NULL THEN
         V_DESC := V_DESC || 'NrTpCustoOp= ' || NVL(:OLD.NRTPCUSTOOP,'') || ' ' ;
      END IF;

      IF :OLD.CDTIPORETI IS NOT NULL THEN
         V_DESC := V_DESC || 'CdTipoReti= ' || NVL(:OLD.CDTIPORETI,'') || ' ' ;
      END IF;

      IF :OLD.CDRETIRESE IS NOT NULL THEN
         V_DESC := V_DESC || 'CdRetiRese= ' || NVL(:OLD.CDRETIRESE,'') || ' ' ;
      END IF;

      IF :OLD.IDGEPERDAREN IS NOT NULL THEN
         V_DESC := V_DESC || 'IdGePerdaRen= ' || NVL(:OLD.IDGEPERDAREN,'') || ' ' ;
      END IF;

      IF :OLD.DTULTATUPMAN IS NOT NULL THEN
         V_DESC := V_DESC || 'DtUltAtuPMan= ' || NVL(:OLD.DTULTATUPMAN,'') || ' ' ;
      END IF;

      IF :OLD.IDSUBOPSEMIACA IS NOT NULL THEN
         V_DESC := V_DESC || 'IdSubOpSemiAca= ' || NVL(:OLD.IDSUBOPSEMIACA,'') || ' ' ;
      END IF;

      IF :OLD.IDBLPRANAINIOP IS NOT NULL THEN
         V_DESC := V_DESC || 'IDBlPranaIniOp= ' || NVL(:OLD.IDBLPRANAINIOP,'') || ' ' ;
      END IF;

      IF :OLD.IDUTSEGLIBLOTE IS NOT NULL THEN
         V_DESC := V_DESC || 'IdUtSegLibLote= ' || NVL(:OLD.IDUTSEGLIBLOTE,'') || ' ' ;
      END IF;

      IF :OLD.IDRESLOTEPEDPLA IS NOT NULL THEN
         V_DESC := V_DESC || 'IdResLotePedPla= ' || NVL(:OLD.IDRESLOTEPEDPLA,'') || ' ' ;
      END IF;

      IF :OLD.IDUTEQUIPLAPROD IS NOT NULL THEN
         V_DESC := V_DESC || 'IdUtEquiPlaProd= ' || NVL(:OLD.IDUTEQUIPLAPROD,'') || ' ' ;
      END IF;

      IF :OLD.IDUTLOCESTPRACA IS NOT NULL THEN
         V_DESC := V_DESC || 'IdUtLocEstPrAca= ' || NVL(:OLD.IDUTLOCESTPRACA,'') || ' ' ;
      END IF;

      IF :OLD.IDVALANARETPROD IS NOT NULL THEN
         V_DESC := V_DESC || 'IdValAnaRetProd= ' || NVL(:OLD.IDVALANARETPROD,'') || ' ' ;
      END IF;

      IF :OLD.IDTPCALCCUSPROD IS NOT NULL THEN
         V_DESC := V_DESC || 'IdTpCalcCusProd= ' || NVL(:OLD.IDTPCALCCUSPROD,'') || ' ' ;
      END IF;

      IF :OLD.IDUTAPPCC IS NOT NULL THEN
         V_DESC := V_DESC || 'IDUTAPPCC= ' || NVL(:OLD.IDUTAPPCC,'') || ' ' ;
      END IF;

      IF :OLD.IDVALINSPRETPRO IS NOT NULL THEN
         V_DESC := V_DESC || 'IdValInspRetPro= ' || NVL(:OLD.IDVALINSPRETPRO,'') || ' ' ;
      END IF;

      IF :OLD.IDPRIORIPROD IS NOT NULL THEN
         V_DESC := V_DESC || 'IdPrioriProd= ' || NVL(:OLD.IDPRIORIPROD,'') || ' ' ;
      END IF;

      IF :OLD.NRRETMAXLOT IS NOT NULL THEN
         V_DESC := V_DESC || 'NrRetMaxLot= ' || NVL(:OLD.NRRETMAXLOT,'') || ' ' ;
      END IF;

      IF :OLD.IDALTERAPCPRET IS NOT NULL THEN
         V_DESC := V_DESC || 'IdAlteraPcpRet= ' || NVL(:OLD.IDALTERAPCPRET,'') || ' ' ;
      END IF;

      IF :OLD.IDLOTEPROD IS NOT NULL THEN
         V_DESC := V_DESC || 'IdLoteProd= ' || NVL(:OLD.IDLOTEPROD,'') || ' ' ;
      END IF;

      IF :OLD.IDAUDIPROCFAB IS NOT NULL THEN
         V_DESC := V_DESC || 'IdAudiProcFab= ' || NVL(:OLD.IDAUDIPROCFAB,'') || ' ' ;
      END IF;

      IF :OLD.IDUTAUTSENHA IS NOT NULL THEN
         V_DESC := V_DESC || 'IdUtAutSenha= ' || NVL(:OLD.IDUTAUTSENHA,'') || ' ' ;
      END IF;

      IF :OLD.IDGERAOPPEDIDO IS NOT NULL THEN
         V_DESC := V_DESC || 'IdGeraOpPedido= ' || NVL(:OLD.IDGERAOPPEDIDO,'') || ' ' ;
      END IF;

      IF :OLD.IDUTAUTSENHARET IS NOT NULL THEN
         V_DESC := V_DESC || 'IdUtAutSenhaRet= ' || NVL(:OLD.IDUTAUTSENHARET,'') || ' ' ;
      END IF;

      IF :OLD.IDTPRETIRADA IS NOT NULL THEN
         V_DESC := V_DESC || 'IdTpRetirada= ' || NVL(:OLD.IDTPRETIRADA,'') || ' ' ;
      END IF;

      IF :OLD.IDALTERARETI IS NOT NULL THEN
         V_DESC := V_DESC || 'IdAlteraReti= ' || NVL(:OLD.IDALTERARETI,'') || ' ' ;
      END IF;

      IF :OLD.IDVDSEMIVDACAB IS NOT NULL THEN
         V_DESC := V_DESC || 'IdVdSemiVdAcab= ' || NVL(:OLD.IDVDSEMIVDACAB,'') || ' ' ;
      END IF;

      IF :OLD.CDFORNECEDBANH IS NOT NULL THEN
         V_DESC := V_DESC || 'CdFornecedBanh= ' || NVL(:OLD.CDFORNECEDBANH,'') || ' ' ;
      END IF;

      IF :OLD.VRSERVICO IS NOT NULL THEN
         V_DESC := V_DESC || 'VrServico= ' || NVL(:OLD.VRSERVICO,'') || ' ' ;
      END IF;

      IF :OLD.VRPROPORCAO IS NOT NULL THEN
         V_DESC := V_DESC || 'VrProporcao= ' || NVL(:OLD.VRPROPORCAO,'') || ' ' ;
      END IF;

      IF :OLD.IDLOTEPRODCOMP IS NOT NULL THEN
         V_DESC := V_DESC || 'IdLoteProdComp= ' || NVL(:OLD.IDLOTEPRODCOMP,'') || ' ' ;
      END IF;

      IF :OLD.IDRETPERDAUTO IS NOT NULL THEN
         V_DESC := V_DESC || 'IdRetPerdAuto= ' || NVL(:OLD.IDRETPERDAUTO,'') || ' ' ;
      END IF;

      IF :OLD.IDLIBLOTEEST IS NOT NULL THEN
         V_DESC := V_DESC || 'IdLibLoteEst= ' || NVL(:OLD.IDLIBLOTEEST,'') || ' ' ;
      END IF;

      IF :OLD.IDALTERAFECHA IS NOT NULL THEN
         V_DESC := V_DESC || 'IdAlteraFecha= ' || NVL(:OLD.IDALTERAFECHA,'') || ' ' ;
      END IF;

      IF :OLD.IDRECALCQTOP IS NOT NULL THEN
         V_DESC := V_DESC || 'IdRecalcQtOp= ' || NVL(:OLD.IDRECALCQTOP,'') || ' ' ;
      END IF;

      IF :OLD.IDUNIDADEVRINT IS NOT NULL THEN
         V_DESC := V_DESC || 'IdUnidadeVrInt= ' || NVL(:OLD.IDUNIDADEVRINT,'') || ' ' ;
      END IF;

      IF :OLD.DSUNIDMEDIDA IS NOT NULL THEN
         V_DESC := V_DESC || 'DsUnidMedida= ' || NVL(:OLD.DSUNIDMEDIDA,'') || ' ' ;
      END IF;

      IF :OLD.CDPRODAGUA IS NOT NULL THEN
         V_DESC := V_DESC || 'CDPRODAGUA= ' || NVL(:OLD.CDPRODAGUA,'') || ' ' ;
      END IF;

      IF :OLD.VRPRODAGUA IS NOT NULL THEN
         V_DESC := V_DESC || 'VRPRODAGUA= ' || NVL(:OLD.VRPRODAGUA,'') || ' ' ;
      END IF;

      IF :OLD.VRULTPRODAGUA IS NOT NULL THEN
         V_DESC := V_DESC || 'VRULTPRODAGUA= ' || NVL(:OLD.VRULTPRODAGUA,'') || ' ' ;
      END IF;

      IF :OLD.IDBLOQFECHA IS NOT NULL THEN
         V_DESC := V_DESC || 'IDBLOQFECHA= ' || NVL(:OLD.IDBLOQFECHA,'') || ' ' ;
      END IF;

      IF :OLD.IDVRUNITPRACAB IS NOT NULL THEN
         V_DESC := V_DESC || 'CalcVrUnitQtReal= ' || NVL(:OLD.IDVRUNITPRACAB,'') || ' ' ;
      END IF;





      IF :OLD.IDUTBALCWTFECHOP IS NOT NULL THEN
         V_DESC := V_DESC || 'IDUTBALCWTFECHOP= ' || NVL(:OLD.IDUTBALCWTFECHOP,'') || ' ' ;
      END IF;

      IF :OLD.IDMODELOBALANCA IS NOT NULL THEN
         V_DESC := V_DESC || 'IDMODELOBALANCA= ' || NVL(:OLD.IDMODELOBALANCA,'') || ' ' ;
      END IF;

      IF :OLD.IDTIPOCONEXAO IS NOT NULL THEN
         V_DESC := V_DESC || 'IDTIPOCONEXAO= ' || NVL(:OLD.IDTIPOCONEXAO,'') || ' ' ;
      END IF;

      IF :OLD.DSIPBALANCA IS NOT NULL THEN
         V_DESC := V_DESC || 'DSIPBALANCA= ' || NVL(:OLD.DSIPBALANCA,'') || ' ' ;
      END IF;

      IF :OLD.CDPORTABALANCA IS NOT NULL THEN
         V_DESC := V_DESC || 'CDPORTABALANCA= ' || NVL(:OLD.CDPORTABALANCA,'') || ' ' ;
      END IF;

      IF :OLD.IDINFPESOMANUAL IS NOT NULL THEN
         V_DESC := V_DESC || 'IDINFPESOMANUAL= ' || NVL(:OLD.IDINFPESOMANUAL,'') || ' ' ;
      END IF;
      V_ITPESQ := :OLD.CDFILIAL   || :OLD.CDPARAMAN;

      V_IDTIPOOPER := '3';

   END IF;

   IF NOT (V_DESC IS NULL) THEN
      V_TAM := LENGTH(V_DESC);
      WHILE (V_TAM >= 0) LOOP
         INSERT INTO LOGOPERA ( NMTABELA, DTOPERACAO, NMRESPOPER,
                                IDTIPOOPER,   DSOPERACAO, CDPESQITEM,
                                DSRDMUSUOPER, DSENDUSUOPER, DSNMUSUOPER,
                                DSMETUSUOPER, CDORESPOPER, CDFILLOGOPER)
                      VALUES  ('PARAMAN', SYSDATE ,    NVL(V_NMOPERADOR,' '),
                                V_IDTIPOOPER,   SUBSTR(V_DESC,1,300), V_ITPESQ,
                                V_DSSERVERRDM, V_DSREMOTEADDR,  V_DSREMOTEHOST,
                                V_DSSERVMETHOD,   V_DSREMOTEOPER, V_CDFILLOGOPER);
         V_DESC := SUBSTR(V_DESC, 300, V_TAM);
         V_TAM := LENGTH(V_DESC);
      END LOOP;

   END IF;
END;