Oracle合并命令错误缺少关键字

Oracle merge command error missing keyword

我正在尝试合并 oracle 中的两个表,我使用的查询是

merge into sales_history sh
 using sales s
 on (s.prod=sh.prod and s.month=sh.month)
 when matched 
      update set sh.amount = s.amount
 when not matched 
      insert (sh.prod,sh.month,sh.amount)
      values (s.prod,s.month,s.amount);

每当我执行这个查询时,我都会收到以下错误:

ORA-00905 missing keyword.

谁能帮我解决这个问题。

 when matched 
      update set sh.amount = s.amount
 when not matched 
      insert (sh.prod,sh.month,sh.amount)

您的 MERGE 语法不正确。您缺少 THEN 关键字。

来自documentation

merge_update_clause ::=

WHEN MATCHED THEN
   UPDATE SET ...

merge_insert_clause ::=

WHEN NOT MATCHED THEN
   INSERT