CREATE OR REPLACE TRIGGER LOG_PED_PEDIDO
AFTER DELETE OR INSERT OR UPDATE
ON PEDIDO FOR EACH ROW
DECLARE
  V_USUARIO      VARCHAR2(40);
  V_TIPO         VARCHAR2(1);
  V_ITPESQ       VARCHAR2(40);
  V_DESC         VARCHAR2(4000);
  V_CDFILLOGOPER VARCHAR2(4);
  V_DSREMOTEADDR VARCHAR2(15);
  V_DSREMOTEHOST VARCHAR2(15);
  V_DSSERVERRDM  VARCHAR2(20);
  V_DSSERVMETHOD VARCHAR2(30);
  V_DSREMOTEOPER VARCHAR2(12);
  V_DTOPER       DATE;
  V_TAM          INTEGER;
  V_STSITPED      VARCHAR2(2);
BEGIN
   V_TIPO := '0';
   V_DESC := '';
   V_CDFILLOGOPER := '';

   IF DELETING THEN
      IF :OLD.CDCLIENTE IS NOT NULL THEN
         V_DESC := V_DESC || 'Cliente=' || :OLD.CDCLIENTE;
      END IF;

      IF :OLD.IDTPIJURTRAN IS NOT NULL THEN
         V_DESC := V_DESC || ' IdTpTransp=' || :OLD.IDTPIJURTRAN;
      END IF;

      IF :OLD.NRINSJURTRAN IS NOT NULL THEN
         V_DESC := V_DESC || ' NrInsTransp=' || :OLD.NRINSJURTRAN;
      END IF;

      IF :OLD.CDTIPTRANS IS NOT NULL THEN
         V_DESC := V_DESC || ' TpTransp=' || :OLD.CDTIPTRANS;
      END IF;

      IF :OLD.CDVENDEDOR IS NOT NULL THEN
         V_DESC := V_DESC || ' CdVend=' || :OLD.CDVENDEDOR;
      END IF;

      IF :OLD.DTPEDIDO IS NOT NULL THEN
         V_DESC := V_DESC || ' DtPed=' || :OLD.DTPEDIDO;
      END IF;

      IF :OLD.DTENTPED IS NOT NULL THEN
         V_DESC := V_DESC || ' DtEntPed=' || :OLD.DTENTPED;
      END IF;

      IF :OLD.IDPRIOPED IS NOT NULL THEN
         V_DESC := V_DESC || ' Prior=' || :OLD.IDPRIOPED;
      END IF;

      IF :OLD.DSPEDCLI IS NOT NULL THEN
         V_DESC := V_DESC || ' DescClie=' || :OLD.DSPEDCLI;
      END IF;

      IF :OLD.DSPEDVEN IS NOT NULL THEN
         V_DESC := V_DESC || ' DescVen=' || :OLD.DSPEDVEN;
      END IF;

      IF :OLD.DTHRLANPED IS NOT NULL THEN
         V_DESC := V_DESC || ' DtLanPed=' || :OLD.DTHRLANPED;
      END IF;

      IF :OLD.CDOPELANPED IS NOT NULL THEN
         V_DESC := V_DESC || ' OperLanPed=' || :OLD.CDOPELANPED;
      END IF;

      IF :OLD.IDSITPEDIDO IS NOT NULL THEN
         IF :OLD.IDSITPEDIDO = '1' THEN V_STSITPED := 'PE'; END IF;
         IF :OLD.IDSITPEDIDO = '2' THEN V_STSITPED := 'AN'; END IF;
         IF :OLD.IDSITPEDIDO = '3' THEN V_STSITPED := 'LQ'; END IF;
         IF :OLD.IDSITPEDIDO = '4' THEN V_STSITPED := 'CN'; END IF;
         IF :OLD.IDSITPEDIDO = '5' THEN V_STSITPED := 'LF'; END IF;
         IF :OLD.IDSITPEDIDO = '6' THEN V_STSITPED := 'PA'; END IF;
         V_DESC := V_DESC || ' SitPed=' || V_STSITPED;
      END IF;

      IF :OLD.IDPGFRETTRAN IS NOT NULL THEN
         V_DESC := V_DESC || ' TpFrete=' || :OLD.IDPGFRETTRAN;
      END IF;

      IF :OLD.CDFORMPGTO IS NOT NULL THEN
         V_DESC := V_DESC || ' CdFormPgto=' || :OLD.CDFORMPGTO;
      END IF;

      IF :OLD.IDTPFORPGTPED IS NOT NULL THEN
         V_DESC := V_DESC || ' IdForPgto=' || :OLD.IDTPFORPGTPED;
      END IF;

      IF :OLD.NRDIAPGFIXPED IS NOT NULL THEN
         V_DESC := V_DESC || ' DiaPgFix=' || :OLD.NRDIAPGFIXPED;
      END IF;

      IF :OLD.NRPARCPGTOPED IS NOT NULL THEN
         V_DESC := V_DESC || ' NrParcPgto=' || :OLD.NRPARCPGTOPED;
      END IF;

      IF :OLD.IDUTDIAPAGPED IS NOT NULL THEN
         V_DESC := V_DESC || ' IdUtDiaPag=' || :OLD.IDUTDIAPAGPED;
      END IF;

      IF :OLD.VRPBRUVOLPED IS NOT NULL THEN
         V_DESC := V_DESC || ' Peso Bruto=' || :OLD.VRPBRUVOLPED;
      END IF;

      IF :OLD.VRPLIQVOLPED IS NOT NULL THEN
         V_DESC := V_DESC || ' Peso Liquido=' || :OLD.VRPLIQVOLPED;
      END IF;

      IF :OLD.CDMODPGTO IS NOT NULL THEN
         V_DESC := V_DESC || ' Mod Pgto=' || :OLD.CDMODPGTO;
      END IF;

      IF :OLD.CDFILIALPED IS NOT NULL THEN
         V_DESC := V_DESC || ' Filial Dest=' || :OLD.CDFILIALPED;
      END IF;

      IF :OLD.IDTIPOPEDIDO IS NOT NULL THEN
         V_DESC := V_DESC || ' Tipo=' || :OLD.IDTIPOPEDIDO;
      END IF;

      IF :OLD.CDPRECOBASE IS NOT NULL THEN
         V_DESC := V_DESC || ' Preco Base=' || :OLD.CDPRECOBASE;
      END IF;

      IF :OLD.CDTIPOOPER IS NOT NULL THEN
         V_DESC := V_DESC || ' Tipo Operacao=' || :OLD.CDTIPOOPER;
      END IF;

      IF :OLD.IDENTRSAIDOP IS NOT NULL THEN
         V_DESC := V_DESC || 'E/S=' || :OLD.IDENTRSAIDOP;
      END IF;

      IF :OLD.DTVALIPED IS NOT NULL THEN
         V_DESC := V_DESC || ' DtValPed=' || :OLD.DTVALIPED;
      END IF;

      IF :OLD.CDROTATRANSPED IS NOT NULL THEN
         V_DESC := V_DESC || ' Rota Ent=' || :OLD.CDROTATRANSPED;
      END IF;

      IF :OLD.DSPRAZOENTPED IS NOT NULL THEN
         V_DESC := V_DESC || ' DsPrazo=' || :OLD.DSPRAZOENTPED;
      END IF;

      IF :OLD.NRORDEMCMPPED IS NOT NULL THEN
         V_DESC := V_DESC || ' Ord. Compra=' || :OLD.NRORDEMCMPPED;
      END IF;

      IF :OLD.IDPEDINDUSTRIA IS NOT NULL THEN
         V_DESC := V_DESC || ' PedInd=' || :OLD.IDPEDINDUSTRIA;
      END IF;

      IF :OLD.IDPEDIDOIMPR IS NOT NULL THEN
         V_DESC := V_DESC || ' Impres=' || :OLD.IDPEDIDOIMPR;
      END IF;

      IF :OLD.NREMPENHO IS NOT NULL THEN
         V_DESC := V_DESC || ' Empenho=' || :OLD.NREMPENHO;
      END IF;

      IF :OLD.CDFILIALORC IS NOT NULL THEN
         V_DESC := V_DESC || ' Fili OrcEv=' || :OLD.CDFILIALORC;
      END IF;

      IF :OLD.NRORCAEVENTO IS NOT NULL THEN
         V_DESC := V_DESC || ' NrOrcEv=' || :OLD.NRORCAEVENTO;
      END IF;

      IF :OLD.NRSEQORCAEVE IS NOT NULL THEN
         V_DESC := V_DESC || ' NrSeqOrcEv=' || :OLD.NRSEQORCAEVE;
      END IF;

      IF :OLD.CDDEPTO IS NOT NULL THEN
         V_DESC := V_DESC || ' Dep=' || :OLD.CDDEPTO;
      END IF;

      IF :OLD.IDORIGPED IS NOT NULL THEN
         V_DESC := V_DESC || ' OrigPed=' || :OLD.IDORIGPED;
      END IF;

      IF :OLD.VRMULTICASH IS NOT NULL THEN
         V_DESC := V_DESC || ' VrMultCash=' || :OLD.VRMULTICASH;
      END IF;

      IF :OLD.VRBONIFICACAO IS NOT NULL THEN
         V_DESC := V_DESC || ' VrBoni=' || :OLD.VRBONIFICACAO;
      END IF;

      IF :OLD.DSNFVENDAFUTURA IS NOT NULL THEN
         V_DESC := V_DESC || ' Vend.Fut=' || :OLD.DSNFVENDAFUTURA;
      END IF;

      IF :OLD.CDTIPORECE IS NOT NULL THEN
         V_DESC := V_DESC || ' TipoRecb=' || :OLD.CDTIPORECE;
      END IF;

      IF :OLD.CDFILLANCA IS NOT NULL THEN
         V_DESC := V_DESC || ' FiliLanc=' || :OLD.CDFILLANCA;
      END IF;

      IF :OLD.CDFILSOLI IS NOT NULL THEN
         V_DESC := V_DESC || ' FiliSoli=' || :OLD.CDFILSOLI;
      END IF;

      IF :OLD.NRSOLICMP IS NOT NULL THEN
         V_DESC := V_DESC || ' NrSoliCmp=' || :OLD.NRSOLICMP;
      END IF;

      IF :OLD.NRSEQDIAPROD IS NOT NULL THEN
         V_DESC := V_DESC || ' NrSeqDiaProd=' || :OLD.NRSEQDIAPROD;
      END IF;

      IF :OLD.NRSEQORCAMENTO IS NOT NULL THEN
         V_DESC := V_DESC || ' NrSeqOrc=' || :OLD.NRSEQORCAMENTO;
      END IF;

      IF :OLD.NREXPEDIDO IS NOT NULL THEN
         V_DESC := V_DESC || ' NrPedExt=' || :OLD.NREXPEDIDO;
      END IF;

      IF :OLD.CDVIATURA IS NOT NULL THEN
         V_DESC := V_DESC || ' Veic=' || :OLD.CDVIATURA;
      END IF;

      IF :OLD.CDMOTORISTA IS NOT NULL THEN
         V_DESC := V_DESC || ' Mot=' || :OLD.CDMOTORISTA;
      END IF;

      IF :OLD.CDMOTORAJUDA IS NOT NULL THEN
         V_DESC := V_DESC || ' MotAjud=' || :OLD.CDMOTORAJUDA;
      END IF;

      IF :OLD.NRPLACAVEPED IS NOT NULL THEN
         V_DESC := V_DESC || ' Placa=' || :OLD.NRPLACAVEPED;
      END IF;

      IF :OLD.SGUFVEICPED IS NOT NULL THEN
         V_DESC := V_DESC || ' UFVeic=' || :OLD.SGUFVEICPED;
      END IF;

      IF :OLD.DSQTDEVOLPED IS NOT NULL THEN
         V_DESC := V_DESC || ' QtVolumes=' || :OLD.DSQTDEVOLPED;
      END IF;

      IF :OLD.DSESPEVOLPED IS NOT NULL THEN
         V_DESC := V_DESC || ' Especie=' || :OLD.DSESPEVOLPED;
      END IF;

      IF :OLD.DSMARCVOLPED IS NOT NULL THEN
         V_DESC := V_DESC || ' MarcaVol=' || :OLD.DSMARCVOLPED;
      END IF;

      IF :OLD.DSNUMEVOLPED IS NOT NULL THEN
         V_DESC := V_DESC || ' NrVolumes=' || :OLD.DSNUMEVOLPED;
      END IF;

      V_TIPO         := '3';
      V_ITPESQ       := :OLD.CDFILIAL||:OLD.NRPEDIDO;
      V_CDFILLOGOPER := :OLD.CDFILIAL;
   ELSE
      IF UPDATING THEN
         IF (NVL(:OLD.CDCLIENTE, '!')       <> NVL(:NEW.CDCLIENTE, '!'))       OR
            (NVL(:OLD.IDTPIJURTRAN, '!')    <> NVL(:NEW.IDTPIJURTRAN, '!'))    OR
            (NVL(:OLD.NRINSJURTRAN, '!')    <> NVL(:NEW.NRINSJURTRAN, '!'))    OR
            (NVL(:OLD.CDTIPTRANS, '!')      <> NVL(:NEW.CDTIPTRANS, '!'))      OR
            (NVL(:OLD.CDVENDEDOR, '!')      <> NVL(:NEW.CDVENDEDOR, '!'))      OR
            (:OLD.DTPEDIDO                  <> :NEW.DTPEDIDO)                  OR
            (:OLD.DTENTPED                  <> :NEW.DTENTPED)                  OR
            (NVL(:OLD.IDPRIOPED, '!')       <> NVL(:NEW.IDPRIOPED, '!'))       OR
            (NVL(:OLD.DSPEDCLI, '!')        <> NVL(:NEW.DSPEDCLI, '!'))        OR
            (NVL(:OLD.DSPEDVEN, '!')        <> NVL(:NEW.DSPEDVEN, '!'))        OR
            (:OLD.DTHRLANPED                <> :NEW.DTHRLANPED)                OR
            (NVL(:OLD.CDOPELANPED, '!')     <> NVL(:NEW.CDOPELANPED, '!'))     OR
            (NVL(:OLD.IDSITPEDIDO, '!')     <> NVL(:NEW.IDSITPEDIDO, '!'))     OR
            (NVL(:OLD.IDPGFRETTRAN, '!')    <> NVL(:NEW.IDPGFRETTRAN, '!'))    OR
            (NVL(:OLD.CDFORMPGTO, '!')      <> NVL(:NEW.CDFORMPGTO, '!'))      OR
            (NVL(:OLD.IDTPFORPGTPED, '!')   <> NVL(:NEW.IDTPFORPGTPED, '!'))   OR
            (:OLD.NRDIAPGFIXPED             <> :NEW.NRDIAPGFIXPED)             OR
            (:OLD.NRPARCPGTOPED             <> :NEW.NRPARCPGTOPED)             OR
            (NVL(:OLD.IDUTDIAPAGPED, '!')   <> NVL(:NEW.IDUTDIAPAGPED, '!'))   OR
            (:OLD.VRPBRUVOLPED              <> :NEW.VRPBRUVOLPED)              OR
            (:OLD.VRPLIQVOLPED              <> :NEW.VRPLIQVOLPED)              OR
            (NVL(:OLD.CDMODPGTO, '!')       <> NVL(:NEW.CDMODPGTO, '!'))       OR
            (NVL(:OLD.CDFILIALPED, '!')     <> NVL(:NEW.CDFILIALPED, '!'))     OR
            (NVL(:OLD.IDTIPOPEDIDO, '!')    <> NVL(:NEW.IDTIPOPEDIDO, '!'))    OR
            (NVL(:OLD.CDPRECOBASE, '!')     <> NVL(:NEW.CDPRECOBASE, '!'))     OR
            (NVL(:OLD.CDTIPOOPER, '!')      <> NVL(:NEW.CDTIPOOPER, '!'))      OR
            (NVL(:OLD.IDENTRSAIDOP, '!')    <> NVL(:NEW.IDENTRSAIDOP, '!'))    OR
            (:OLD.DTVALIPED                 <> :NEW.DTVALIPED)                 OR
            (NVL(:OLD.CDROTATRANSPED, '!')  <> NVL(:NEW.CDROTATRANSPED, '!'))  OR
            (NVL(:OLD.DSPRAZOENTPED, '!')   <> NVL(:NEW.DSPRAZOENTPED, '!'))   OR
            (NVL(:OLD.NRORDEMCMPPED, '!')   <> NVL(:NEW.NRORDEMCMPPED, '!'))   OR
            (NVL(:OLD.IDPEDINDUSTRIA, '!')  <> NVL(:NEW.IDPEDINDUSTRIA, '!'))  OR
            (NVL(:OLD.IDPEDIDOIMPR, '!')    <> NVL(:NEW.IDPEDIDOIMPR, '!'))    OR
            (NVL(:OLD.NREMPENHO, '!')       <> NVL(:NEW.NREMPENHO, '!'))       OR
            (NVL(:OLD.CDFILIALORC, '!')     <> NVL(:NEW.CDFILIALORC, '!'))     OR
            (NVL(:OLD.NRORCAEVENTO, '!')    <> NVL(:NEW.NRORCAEVENTO, '!'))    OR
            (NVL(:OLD.NRSEQORCAEVE, '!')    <> NVL(:NEW.NRSEQORCAEVE, '!'))    OR
            (NVL(:OLD.CDDEPTO, '!')         <> NVL(:NEW.CDDEPTO, '!'))         OR
            (NVL(:OLD.IDORIGPED, '!')       <> NVL(:NEW.IDORIGPED, '!'))       OR
            (:OLD.VRMULTICASH               <> :NEW.VRMULTICASH)               OR
            (:OLD.VRBONIFICACAO             <> :NEW.VRBONIFICACAO)             OR
            (NVL(:OLD.DSNFVENDAFUTURA, '!') <> NVL(:NEW.DSNFVENDAFUTURA, '!')) OR
            (NVL(:OLD.CDTIPORECE, '!')      <> NVL(:NEW.CDTIPORECE, '!'))      OR
            (NVL(:OLD.CDFILLANCA, '!')      <> NVL(:NEW.CDFILLANCA, '!'))      OR
            (NVL(:OLD.CDFILSOLI, '!')       <> NVL(:NEW.CDFILSOLI, '!'))       OR
            (NVL(:OLD.NRSOLICMP, '!')       <> NVL(:NEW.NRSOLICMP, '!'))       OR
            (NVL(:OLD.NRSEQDIAPROD, '!')    <> NVL(:NEW.NRSEQDIAPROD, '!'))    OR
            (:OLD.NRSEQORCAMENTO            <> :NEW.NRSEQORCAMENTO)            OR
            (NVL(:OLD.NREXPEDIDO, '!')      <> NVL(:NEW.NREXPEDIDO, '!'))      OR
            (NVL(:OLD.CDVIATURA, '!')       <> NVL(:NEW.CDVIATURA, '!'))       OR
            (NVL(:OLD.CDMOTORISTA, '!')     <> NVL(:NEW.CDMOTORISTA, '!'))     OR
            (NVL(:OLD.CDMOTORAJUDA, '!')    <> NVL(:NEW.CDMOTORAJUDA, '!'))    OR
            (NVL(:OLD.NRPLACAVEPED, '!')    <> NVL(:NEW.NRPLACAVEPED, '!'))    OR
            (NVL(:OLD.SGUFVEICPED, '!')     <> NVL(:NEW.SGUFVEICPED, '!'))     OR
            (NVL(:OLD.DSQTDEVOLPED, '!')    <> NVL(:NEW.DSQTDEVOLPED, '!'))    OR
            (NVL(:OLD.DSESPEVOLPED, '!')    <> NVL(:NEW.DSESPEVOLPED, '!'))    OR
            (NVL(:OLD.DSMARCVOLPED, '!')    <> NVL(:NEW.DSMARCVOLPED, '!'))    OR
            (NVL(:OLD.DSNUMEVOLPED, '!')    <> NVL(:NEW.DSNUMEVOLPED, '!'))    THEN

            V_TIPO         := '2';
            V_ITPESQ       := :OLD.CDFILIAL||:OLD.NRPEDIDO;
            V_CDFILLOGOPER := :OLD.CDFILIAL;
         END IF;
      ELSE
         V_TIPO         := '1';
         V_ITPESQ       := :NEW.CDFILIAL||:NEW.NRPEDIDO;
         V_CDFILLOGOPER := :NEW.CDFILIAL;
      END IF;

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

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

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

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

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

      IF (:NEW.DTPEDIDO IS NOT NULL) AND (:NEW.DTPEDIDO <> :OLD.DTPEDIDO) THEN
         V_DESC := V_DESC || ' DtPed=' || :NEW.DTPEDIDO;
      END IF;

      IF (:NEW.DTENTPED IS NOT NULL) AND (:NEW.DTENTPED <> :OLD.DTENTPED) THEN
         V_DESC := V_DESC || ' DtEntPed=' || :NEW.DTENTPED;
      END IF;

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

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

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

      IF (:NEW.DTHRLANPED IS NOT NULL) AND (:NEW.DTHRLANPED <> :OLD.DTHRLANPED) THEN
         V_DESC := V_DESC || ' DtLanPed=' || :NEW.DTHRLANPED;
      END IF;

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

      IF NVL(:NEW.IDSITPEDIDO, '!') <> NVL(:OLD.IDSITPEDIDO, '!') THEN
         IF :NEW.IDSITPEDIDO = '1' THEN V_STSITPED := 'PE'; END IF;
         IF :NEW.IDSITPEDIDO = '2' THEN V_STSITPED := 'AN'; END IF;
         IF :NEW.IDSITPEDIDO = '3' THEN V_STSITPED := 'LQ'; END IF;
         IF :NEW.IDSITPEDIDO = '4' THEN V_STSITPED := 'CN'; END IF;
         IF :NEW.IDSITPEDIDO = '5' THEN V_STSITPED := 'LF'; END IF;
         IF :NEW.IDSITPEDIDO = '6' THEN V_STSITPED := 'PA'; END IF;
         V_DESC := V_DESC || ' SitPed=' || V_STSITPED;
      END IF;

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

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

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

      IF (:NEW.NRDIAPGFIXPED IS NOT NULL) AND (:NEW.NRDIAPGFIXPED <> :OLD.NRDIAPGFIXPED) THEN
         V_DESC := V_DESC || ' DiaPgFix=' || :NEW.NRDIAPGFIXPED;
      END IF;

      IF (:NEW.NRPARCPGTOPED IS NOT NULL) AND (:NEW.NRPARCPGTOPED <> :OLD.NRPARCPGTOPED) THEN
         V_DESC := V_DESC || ' NrParcPgto=' || :NEW.NRPARCPGTOPED;
      END IF;

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

      IF (:NEW.VRPBRUVOLPED IS NOT NULL) AND (:NEW.VRPBRUVOLPED <> :OLD.VRPBRUVOLPED) THEN
         V_DESC := V_DESC || ' Peso Bruto=' || :NEW.VRPBRUVOLPED;
      END IF;

      IF (:NEW.VRPLIQVOLPED IS NOT NULL) AND (:NEW.VRPLIQVOLPED <> :OLD.VRPLIQVOLPED) THEN
         V_DESC := V_DESC || ' Peso Liquido=' || :NEW.VRPLIQVOLPED;
      END IF;

      IF NVL(:NEW.CDMODPGTO, '!') <> NVL(:OLD.CDMODPGTO, '!') THEN
         V_DESC := V_DESC || ' Mod Pgto=' || :NEW.CDMODPGTO;
      END IF;

      IF NVL(:NEW.CDFILIALPED, '!') <> NVL(:OLD.CDFILIALPED, '!') THEN
         V_DESC := V_DESC || ' Filial Dest=' || :NEW.CDFILIALPED;
      END IF;

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

      IF NVL(:NEW.CDPRECOBASE, '!') <> NVL(:OLD.CDPRECOBASE, '!') THEN
         V_DESC := V_DESC || ' Preco Base=' || :NEW.CDPRECOBASE;
      END IF;

      IF NVL(:NEW.CDTIPOOPER, '!') <> NVL(:OLD.CDTIPOOPER, '!') THEN
         V_DESC := V_DESC || ' Tipo Operacao=' || :NEW.CDTIPOOPER;
      END IF;

      IF NVL(:NEW.IDENTRSAIDOP, 1) <> NVL(:OLD.IDENTRSAIDOP, 1) THEN
         V_DESC := V_DESC || ' E/S=' || :NEW.IDENTRSAIDOP;
      END IF;

      IF (:NEW.DTVALIPED IS NOT NULL) AND (:NEW.DTVALIPED <> :OLD.DTVALIPED) THEN
         V_DESC := V_DESC || ' DtValPed=' || :NEW.DTVALIPED;
      END IF;

      IF NVL(:NEW.CDROTATRANSPED, '!') <> NVL(:OLD.CDROTATRANSPED, '!') THEN
         V_DESC := V_DESC || ' Rota Ent=' || :NEW.CDROTATRANSPED;
      END IF;

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

      IF NVL(:NEW.NRORDEMCMPPED, '!') <> NVL(:OLD.NRORDEMCMPPED, '!') THEN
         V_DESC := V_DESC || ' Ord. Compra=' || :NEW.NRORDEMCMPPED;
      END IF;

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

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

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

      IF NVL(:NEW.CDFILIALORC, '!') <> NVL(:OLD.CDFILIALORC, '!') THEN
         V_DESC := V_DESC || ' Fili. OrcEv=' || :NEW.CDFILIALORC;
      END IF;

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

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

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

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

      IF (:NEW.VRMULTICASH IS NOT NULL) AND (:NEW.VRMULTICASH <> :OLD.VRMULTICASH) THEN
         V_DESC := V_DESC || ' VrMultCash=' || :NEW.VRMULTICASH;
      END IF;

      IF (:NEW.VRBONIFICACAO IS NOT NULL) AND (:NEW.VRBONIFICACAO <> :OLD.VRBONIFICACAO) THEN
         V_DESC := V_DESC || ' VrBoni=' || :NEW.VRBONIFICACAO;
      END IF;

      IF NVL(:NEW.DSNFVENDAFUTURA, '!') <> NVL(:OLD.DSNFVENDAFUTURA, '!') THEN
         V_DESC := V_DESC || ' Vend.Fut=' || :NEW.DSNFVENDAFUTURA;
      END IF;

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

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

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

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

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

      IF (:NEW.NRSEQORCAMENTO IS NOT NULL) AND (:NEW.NRSEQORCAMENTO <> :OLD.NRSEQORCAMENTO) THEN
         V_DESC := V_DESC || ' NrSeqOrc=' || :NEW.NRSEQORCAMENTO;
      END IF;

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

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

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

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

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

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

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

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

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

      IF NVL(:NEW.DSNUMEVOLPED, '!') <> NVL(:OLD.DSNUMEVOLPED, '!') THEN
         V_DESC := V_DESC || ' NrVolumes=' || :NEW.DSNUMEVOLPED;
      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;
            V_TAM := LENGTH(V_DESC);
            WHILE (V_TAM >= 0) LOOP

               INSERT INTO LOGOPERA
                  (NMTABELA,
                   DTOPERACAO,
                   NMRESPOPER,
                   IDTIPOOPER,
                   CDPESQITEM,
                   DSOPERACAO,
                   CDFILLOGOPER,
                   DSRDMUSUOPER,
                   DSENDUSUOPER,
                   DSNMUSUOPER,
                   DSMETUSUOPER,
                   CDORESPOPER)
               VALUES
                  ('PEDIDO',
                   V_DTOPER,
                   V_USUARIO,
                   V_TIPO,
                   V_ITPESQ,
                   SUBSTR(V_DESC,1,700),
                   V_CDFILLOGOPER,
                   V_DSSERVERRDM,
                   V_DSREMOTEADDR,
                   V_DSREMOTEHOST,
                   V_DSSERVMETHOD,
                   V_DSREMOTEOPER);
               V_DESC := SUBSTR(V_DESC, 700, V_TAM);
               V_TAM := LENGTH(V_DESC);
            END LOOP;
         END IF;
      END IF;
   END IF;
END;
/