title: when matched update not working oracle merge
body: <p>Here is something interesting! The <code>merge</code> statement works fine. But when the values match, it does not update the status to 'B' as expected. Any idea why? </p>
  
  <pre><code>merge into bbbt b 
  using (select bank,ifsc,branch,
                center,district,state,
                address,status 
           from rtgbrn_temp 
          where ifsc in (SELECT ifsc 
                           FROM rtgbrn_temp 
                          MINUS 
                         SELECT ifsc_code 
                           FROM bbbt)
          ) x
     on (x.ifsc = b.ifsc_code)
   when matched then 
     update 
        set rtgs_stat = 'B' 
      where (x.ifsc=b.ifsc_code)
   when not matched then 
     insert (bankid,benbrn_code,brn_name,
             brn_addr,brn_loc,brn_stat,
             brn_city,coun_code,
             remarks,ifsc_code,
             rtgs_stat)
     values (substr(x.ifsc,1,4), substr(x.ifsc,5), 
             x.branch, x.address, x.district, 
             x.state, x.center,'IN', x.bank, x.ifsc,'R');
  </code></pre>
  
  <p>[also tried using the on duplicate update, but failed to work with an error]</p>
  
  <pre><code>SQL Error: ORA-00933: SQL command not properly ended!
  
  insert into bbbt(bankid,benbrn_code,brn_name,brn_addr,brn_loc,brn_stat,brn_city,coun_code,remarks,ifsc_code,rtgs_stat)
  select substr(x.ifsc,1,4), substr(x.ifsc,5), x.branch, x.address, x.district, x.state, x.center,'IN', x.bank, x.ifsc,'R' from 
  (select bank,ifsc,branch,center,district,state,address,status from rtgbrn_temp where ifsc in (SELECT ifsc FROM rtgbrn_temp MINUS SELECT ifsc_code FROM bbbt))x
  ON DUPLICATE KEY UPDATE rtgs_stat = 'B'; 
  </code></pre>
  
  <p>please share your knowledge, thanks!</p>