title: Firedac Firebird master-detail scenario
body: <p>I have master detail </p>
  
  <p><code>CachedUpdates</code> for the master <code>true</code><br>
  <code>CachedUpdates</code> for the detail <code>true</code><br>
  <code>DetailCascde</code> for the detail <code>true</code></p>
  
  <p>The master deals with one record:</p>
  
  <pre><code>select * from orders where order_id=:order 
  </code></pre>
  
  <p>First I pass -1 as dummy parameter to get an empty master record:</p>
  
  <pre><code>orders.Close;
  orders.Params[0].AsInteger := -1;
  orders.Open;
  </code></pre>
  
  <p>Than I fill the order id with -1 to build the relationship between the master and the detail:</p>
  
  <pre><code>orders.Append;
  orders.Fields[0].AsInteger := -1;
  orders.Post;
  </code></pre>
  
  <p>I insert into the detail successfully with <code>Append</code> and <code>Post</code> </p>
  
  <p>The problem is in the Firebird database I have this line on before insert trigger for the master </p>
  
  <pre><code>new.order_id = coalesce((select max(order_id) from orders) + 1, 1);
  </code></pre>
  
  <p>I ApplyUpdates </p>
  
  <pre><code>Orders.ApplyUpdates(-1);
  dOrder.ApplyUpdates(-1);
  </code></pre>
  
  <p>So when I ApplyUpdates for the master, the detail won't apply because the master id is altered by the server.</p>
  
  <p>How to solve such scenario?</p>