-- Created on 2008-7-4 by PP declare -- Local variables here cursor a_cursor is select a,b from A; begin -- Test statements here for A_record in a_cursor loop if A_record.a=A_record.b then update B set c='' where a=A_record.a and b=A_record.b; dbms_output.put_line('表B更新成功'); else dbms_output.put_line('表B更新失败'); end if; end loop; exception when sql%notfound then dbms_output.put_line('表B更新失败'); end; 楼主看看,是不是这样的?
using b on (a.id=b.id)
when matched update
when not matched insert 这样可以使用,查查看
楼主的要求,megert实现不了,只能用存储过程
declare
-- Local variables here
cursor a_cursor is
select a,b from A;
begin
-- Test statements here
for A_record in a_cursor loop
if A_record.a=A_record.b then
update B set c='' where a=A_record.a and b=A_record.b;
dbms_output.put_line('表B更新成功');
else
dbms_output.put_line('表B更新失败');
end if;
end loop;
exception
when sql%notfound then
dbms_output.put_line('表B更新失败');
end;
楼主看看,是不是这样的?