title: ORA-00905: missing keyword in a Merge statement
body: <p>I'm writing a little piece of code for an University exercise, but I can't get it to work. I want to join Impiegato and Anagrafica rows on Cod only when Anagrafica's row has no null fields. Then for each row of the new temporary table I generate a string (some_string) and this string will be the value of the Report field in ReportImpiegato table. I'm using Oracle 11g and SQL Developer. Thanks in advance to everyone willing to help. :-)</p>
  
  <p>My tables are:</p>
  
  <pre><code>TABLE IMPIEGATO
  COD NUMBER(4,0)
  NOME    VARCHAR2(40 BYTE)
  COGNOME VARCHAR2(40 BYTE)
  DATA_ASSUNTO    DATE
  STIPENDIO   NUMBER(8,2)
  CAPO    NUMBER(4,0)
  
  TABLE ANAGRAFICA
  COD NUMBER(4,0)
  DATAN   DATE
  SESSO   CHAR(1 BYTE)
  LUOGON  VARCHAR2(80 BYTE)
  PROVN   CHAR(2 BYTE)
  
  TABLE REPORTIMPIEGATO
  COD NUMBER
  REPORT  VARCHAR2(4000 BYTE)
  </code></pre>
  
  <p>And my code is:</p>
  
  <pre><code>MERGE INTO ReportImpiegato R
  USING (SELECT * FROM (
      (SELECT *
      FROM Anagrafica A
      WHERE (A.DATAN IS NOT NULL AND A.LUOGON IS NOT NULL AND A.PROVN IS NOT NULL AND A.SESSO IS NOT NULL)) A 
      JOIN
      (Impiegato I)
      ON (A.Cod = I.Cod)
    )) D
  ON (R.Cod = D.Cod)
  WHEN MATCHED THEN
      UPDATE SET R.Report = some_string
  WHEN NOT MATCHED
      INSERT (Cod, Report) VALUES (D.Cod, some_string)
  </code></pre>
  
  <p>Output is:</p>
  
  <pre><code>Error starting at line : 1 in command -
  MERGE INTO ReportImpiegato R
  USING (SELECT * FROM (
          (SELECT * FROM Anagrafica A WHERE (A.DATAN IS NOT NULL AND A.LUOGON IS     NOT NULL AND A.PROVN IS NOT NULL AND A.SESSO IS NOT NULL)) A 
          JOIN
          (Impiegato I)
          ON (A.Cod = I.Cod)
        )) D
  ON (R.Cod = D.Cod)
  WHEN MATCHED THEN
      UPDATE SET R.Report = some_string
  WHEN NOT MATCHED
      INSERT (Cod, Report) VALUES (D.Cod, some_string);
  Error at Command Line : 14 Column : 5
  Error report -
  SQL Error: ORA-00905: missing keyword
  00905. 00000 -  "missing keyword"
  *Cause:    
  *Action:
  </code></pre>