执行merge不会返回影响的行数,最多只能两个表关联。
merge into a using b on (a.c1=b.c1 and a.c3='2011') when matched then update a.c2=b.c2
四、快速游标更新法(复杂逻辑时,效率很高)
语法:
begin for cr in (查询语句) loop --循环 update table_name set ... --更新语句(根据查询出来的结果集合) end loop; --结束循环 end;
begin for cur in (select a.rowid ,b.c2 from a, b where a.c1=b.c1 and a.c3='2011' ) loop UPDATE a set c2=cur.c2 where rowid=cur.rowid; end loop; end;