因此,在您的情况下,其外观应为:...WHEN MATCHEDTHEN UPDATE SET tgt.column3= src.column3, tgt.column4 = src.coulmn4 WHERE tgt.column3 IN (val1, val2) WHEN NOT MATCHED...I have to insert/update some RECORDS in table target_table. These records are coming one source_table. I am using MERGE for update/insert in target_table. Query is as belowMERGE INTO target_table tgt USING source_table src ON ( src.column1 = tgt.column1 and src.column2 = tgt.column2)WHEN MATCHEDTHEN UPDATE SET tgt.column3= src.column3, tgt.column4 = src.coulmn4 WHEN NOT MATCHED THENINSERT ( tgt.column1, tgt.column2, tgt.column3, tgt.column4 )VALUES ( src.coulmn1, src.coulmn2, src.coulmn3, src.coulmn4);I want to add some specific condition on update.IF target_table.column3 in (val1','val2)then only there should be update, else no update or insert. 解决方案 You can simply add WHERE clause to UPDATE. More about it in oracle docs.So in your case it should look like:...WHEN MATCHEDTHEN UPDATE SET tgt.column3= src.column3, tgt.column4 = src.coulmn4 WHERE tgt.column3 IN (val1, val2) WHEN NOT MATCHED... 这篇关于想要在oracle sql的MERGE语句中添加一些条件以进行插入/更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-11 23:54