Oracle(DB관련)
merge into 있으면 update, 없으면 insert
xfree302
2009. 11. 3. 16:38
반응형
merge into tb_a a
using dual
on (a.code = ?)
when matched then
update set name = '있다'
when not matched then
insert (code, name) values (?, '없다')
merge into tb_aaa a
using (select code, name tb_bbb where code=?) b
on (a.code = b.code)
when matched then
update set a.name = b.namel
when not matched then
insert (a.code, a.name ) values (b.code, b.namel );
반응형