title: Oracle CTE Merge
body: <p>I am trying a simple merge statement using a CTE(Common table expression) . But it gives an error </p>
  
  <pre><code>MERGE INTO  emp targ USING (
  *
  ERROR at line 4:
  ORA-00928: missing SELECT keyword
  </code></pre>
  
  <p>Is the CTE not allowed in a merge statement?  My Sql is below:</p>
  
  <pre><code>WITH cte AS (
    SELECT empno, ename 
      FROM EMP)
  MERGE INTO emp targ USING (SELECT * 
                               FROM cte) src
    ON (targ.empno = src.empno)
  WHEN MATCHED THEN update 
     SET targ.ename = src.ename
  WHEN NOT MATCHED THEN insert
      (empno,ename)
    VALUES
      (src.empno,src.ename)
  /
  </code></pre>