title: SQL merge on in DB2 running on AS400, 6.1
body: <p>The following query does not work in DB2 which is running on the As400. I've read of similar <a href="https://stackoverflow.com/questions/19734001/db2-merge-statement-error">issues</a> but am unsure how to modify my query accordingly.</p>
  
  <pre><code>merge into AB27PR AB
      using (select USER, ROCOMP,REFID, QREADSTAT
               from S490JR
              where QREADSTAT =1) SR
      on
         (AB.USER= SR.USER
          AND AB.XCCOMP = SR.ROCOMP
          AND AB.XEFID = SR.REFID )
      when matched 
       and AB.XREADSTAT = 0
      then update set XREADSTAT = SR.QREADSTAT;
  </code></pre>