Sql 匹配后插入合并

Sql 匹配后插入合并,sql,oracle,sql-update,subquery,sql-insert,Sql,Oracle,Sql Update,Subquery,Sql Insert,我试过这个sql merge into params t using ( select '9158075153713931109' ATTR_ID, '9158310272413033579' OBJECT_ID, '9158075157713931109' LIST_VALUE_ID from dual where exists (select * from attributes where attr_id = 9158075153713931109) ) v o

我试过这个sql

merge into params t
using (
    select '9158075153713931109' ATTR_ID, '9158310272413033579' OBJECT_ID,
'9158075157713931109' LIST_VALUE_ID
from dual
    where exists (select * from attributes where attr_id = 9158075153713931109)
       ) v
on (t.object_id = v.object_id)
when matched then insert (attr_id, object_id, list_value_id, show_order) values(v.attr_id,v.object_id, v.LIST_VALUE_ID,1);
这里我只需要在attr_id(9158075153713931109)存在时将值插入params。 我理解只有更新和删除与“匹配时”一起使用 请帮助我如何使用merge执行此操作

仅当attr_id(9158075153713931109)存在时,我才需要将该值插入params

我不认为这里的
merge
语句有什么意义。据我所知,你的要求是:

insert int params (attr_id, object_id, list_value_id, show_order) 
select s.*, 1
from (select '9158075153713931109' attr_id, '9158310272413033579' object_id, '9158075157713931109' list_value_id from dual) s 
where exists (select 1 from attributes a where a.attr_id = s.attr_id)