title: Oracle merge statement and by source/target condition
body: <p>I need to do a <code>MERGE</code> in Oracle, but I'm stuck.</p>
  
  <p>In SQL Server, I always use the <code>BY SOURCE</code> and <code>BY TARGET</code> condition to check where record exists, and then take an action.</p>
  
  <p>I'm a little confused because I don't know how to achieve the same in PL/SQL.
  I need to do a <code>MERGE</code> on two tables (<code>customers</code> and <code>customers_stage</code>).</p>
  
  <ul>
  <li>If the record does not exists in the customer table - then insert. </li>
  <li>If the record exits in both - then update.</li>
  <li>If the record does not exists in customers_stage - then delete.</li>
  </ul>
  
  <p>In SQL Server, it would look like this:</p>
  
  <pre><code>MERGE INTO dbo.Customers AS target
  USING dbo.Customers_stage AS source ON target.ID = source.ExternalID
  
  WHEN NOT MATCHED BY TARGET 
     THEN 
        INSERT
  
  WHEN MATCHED 
     THEN
        UPDATE
  
  WHEN NOT MATCHED BY SOURCE 
     THEN
        DELETE
  </code></pre>
  
  <p>How to achieve the same functionality in Oracle? I use SQL Developer.</p>
  
  <p>Thank you very much.</p>