create or replace procedure sp_rpt_update is cursor c1 is select id ,phone,condition from B@dblink; v_id A.id%type; v_phone A.phone%type; v_condition A.condition%type; v1 number; begin open c1; loop fetch c1 into v_id,v_phone,v_condition; exit when c1%notfound; begin select 1 into v1 from A where id=v_id; if v1=1 then update A set conditon=v_condition,phone=v_phone;end if; exception when others then insert into A values(v_id,v_phone,v_condition); end; commit; end loop;close c1; exception when others then rollback;end;
上面的更新用这个 掉了条件 update A set conditon=v_condition,phone=v_phone where id =v_id;
is
cursor c1 is select id ,phone,condition from B@dblink;
v_id A.id%type;
v_phone A.phone%type;
v_condition A.condition%type;
v1 number;
begin
open c1;
loop
fetch c1 into v_id,v_phone,v_condition;
exit when c1%notfound;
begin
select 1 into v1 from A where id=v_id;
if v1=1 then
update A set conditon=v_condition,phone=v_phone;end if;
exception
when others then
insert into A values(v_id,v_phone,v_condition);
end;
commit;
end loop;close c1;
exception
when others then
rollback;end;
update A set conditon=v_condition,phone=v_phone where id =v_id;