title: Merge query returning ORA-30926: unable to get a stable set of rows in the source tables
body: <p>I have two merge queries which triggers one after another </p>
  
  <p><strong>First Query</strong></p>
  
  <pre><code>merge into MyTable
  using
  (   
  select distinct nullLogSetId.Id as IdToUpdate,
         knownLogSetId.LogSetId LogSetIdToUpdateTo
  from MyTable knownLogSetId 
  join MyTable nullLogSetId
    on knownLogSetId.IdentifierType = nullLogSetId.IdentifierType
   and knownLogSetId.Identifier = nullLogSetId.Identifier 
  where 
  
      knownLogSetId.IdentifierType = 'ABC'
      and knownLogSetId.LogSetId &gt;= 0 
      and nullLogSetId.LogSetId = -1
  )
  on (Id = IdToUpdate)
  when matched then
  update set LogSetId = LogSetIdToUpdateTo
  </code></pre>
  
  <p><strong>Second Query</strong></p>
  
  <pre><code>merge into MyTable
  using
  (
  
    select distinct nullLogSetId.Id as IdToUpdate,
                    knownLogSetId.LogSetId LogSetIdToUpdateTo
    from MyTable knownLogSetId 
    join MyTable nullLogSetId
      on knownLogSetId.IdentifierType = nullLogSetId.IdentifierType 
     and knownLogSetId.Identifier = nullLogSetId.Identifier 
    where 
      knownLogSetId.IdentifierType = 'DEF'
      and knownLogSetId.LogSetId &gt;= 0 
      and nullLogSetId.LogSetId = -1
  ) on (Id = IdToUpdate)
  when matched then
  update set LogSetId = LogSetIdToUpdateTo
  </code></pre>
  
  <p>I am calling these queries from .NET one after another using OracleCommand</p>
  
  <p>The first works fine but when second gets triggered i am getting error </p>
  
  <blockquote>
    <p><strong>ORA-30926: unable to get a stable set of rows in the source tables</strong></p>
  </blockquote>
  
  <p>I have read all the relevent questions and tried from my side as well , if you see i used distinct in both of the queries so duplicating of rows is not an issue.
  Can please anybody help me out what i am i doing wrong , it could be a basic stuff as i am new to queries , please help me out</p>