0
votes

I'm getting this error help me:- ORA-00905: missing keyword

Merge statement in sql

MERGE INTO TEMP1 T
USING (SELECT CHAR_VAR,VCHAR,VAR_CHAR2 FROM VAR_CHECK WHERE CHAR_VAR='Steven' AND VCHAR='King') S
ON (T.AUTHOR=S.CHAR_VAR)
WHEN MATCHED THEN 
UPDATE SET T.SNAME=S.VAR_CHAR2
WHEN NOT MATCHED
INSERT (T.AUTHOR,T.TOPIC,T.SNAME) VALUES (S.CHAR_VAR,S.VCHAR,S.VAR_CHAR2);
1

1 Answers

4
votes

The keyword that is missing is THEN after WHEN NOT MATCHED:

MERGE INTO TEMP1 T
USING (SELECT CHAR_VAR,VCHAR,VAR_CHAR2 FROM VAR_CHECK WHERE CHAR_VAR='Steven' AND VCHAR='King') S
ON (T.AUTHOR=S.CHAR_VAR)
WHEN MATCHED THEN 
UPDATE SET T.SNAME=S.VAR_CHAR2
WHEN NOT MATCHED THEN
INSERT (T.AUTHOR,T.TOPIC,T.SNAME) VALUES (S.CHAR_VAR,S.VCHAR,S.VAR_CHAR2);