我正在尝试在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缺少关键字。
任何人都可以帮助我。
答案 0 :(得分:1)
when matched
update set sh.amount = s.amount
when not matched
insert (sh.prod,sh.month,sh.amount)
您的 MERGE 语法不正确。您错过了THEN
关键字。
来自How to disable VLCMediaPlayer error AlertView?:
merge_update_clause :: =
WHEN MATCHED THEN
UPDATE SET ...
merge_insert_clause :: =
WHEN NOT MATCHED THEN
INSERT