title: How to Modify Field Values in TDataSetProvider.OnUpdateData
body: <p>After reading the Delphi help file about TDataSetProvider.OnUpdateData
  event explanation:</p>
  
  <ol>
  <li>Examine data (for example, for values or data changes that should not permitted), and raise exceptions that cancel applying of updates before they occur.</li>
  <li>Change data (for example encrypting or decrypting values) before it is sent on to the source dataset or database server.</li>
  </ol>
  
  <p>I am looking for a sample code of how to <strong>change data</strong> for OnUpdateData. 
  I have tried my best to look for solution. This is what I can achieve:</p>
  
  <p><strong>Example 1</strong>:</p>
  
  <pre><code>procedure TDBNextDocNo.DSPUpdateData(Sender: TObject; DataSet: TCustomClientDataSet);
  begin
    DataSet.First;
    while not DataSet.EOF do begin
      if DataSet.UpdateStatus = usUnmodified then begin
        TPacketDataSet(Dataset).InitAltRecBuffers(True);
        if DataSet.UpdateStatus in [usInserted, usModified] then begin
          Dataset.Edit;
          DataSet.FindField('MyField').AsString := 'zzz';
          Dataset.Post;
        end;
      end;
    end;
    DataSet.Next;
  end;
  </code></pre>
  
  <p><strong>Problem for Example 1</strong>: Unfortunately, I keep receive error that some field value is missing. After perform some debug, I found that there are required fields that has empty value. </p>
  
  <p><strong>Example 2:</strong></p>
  
  <pre><code>procedure TDBNextDocNo.DSPUpdateData(Sender: TObject; DataSet: TCustomClientDataSet);
  begin
    DataSet.First;
    while not DataSet.EOF do begin
      if DataSet.UpdateStatus = usUnmodified then begin
        TPacketDataSet(Dataset).InitAltRecBuffers(True);
        if DataSet.UpdateStatus in [usInserted, usModified] then 
          DataSet.FindField('MyField').NewValue:= 'zzz';     
      end;
      DataSet.Next;
    end;  
  end;
  </code></pre>
  
  <p><strong>Problem for Example 2</strong>: By writing this way we no need to call DataSet.Edit &amp; DataSet.Post. But the value 'zzz' which set to TField.NewValue is not being saved into database.</p>
  
  <p>I have some special reason that the this update must perform in OnUpdateData instead
  of BeforeUpdateRecord/AfterUpdateRecord.</p>
  
  <p>Please advice. Thank you very much.</p>