title: Oracle - How to use merge to update a column based on the values from other table and columns
body: <p>I would like to update the values in closed_date column based on the values comparison from other columns and other table. I used Oracle merge into statement. But it gave me an error:</p>
  
  <p>Error: ORA-00969: missing ON keyword</p>
  
  <p>I am not sure what goes wrong. Do I miss anything? Below is my script:</p>
  
  <pre><code>MERGE INTO PR_DMN dmn
  USING (select alg.PR_DMN_ID, alg.PR_ACTIVITY_ID, alg.ACTIVITY_TS from PR_ACTIVITY_LOG) alg
  ON dmn.PR_DMN_ID = alg.PR_DMN_ID
  -- update
  WHEN MATCHED THEN
  UPDATE SET dmn.CLOSED_DATE =
      (CASE 
          WHEN alg.PR_ACTIVITY_ID IN ('10009', '10010', '10011', '10013') THEN alg.ACTIVITY_TS
          WHEN alg.PR_ACTIVITY_ID = '10005' AND dmn.CONT_RESP_TS &lt;= dmn.CONT_RESP_DUE_TS THEN dmn.CONT_RESP_TS 
          WHEN alg.PR_ACTIVITY_ID = '10008' AND dmn.CORR_RESP_TS &lt;= dmn.CORR_RESP_DUE_TS THEN dmn.CORR_RESP_TS
          ELSE dmn.CLOSED_DATE 
      END)
  </code></pre>