create or replace procedure p_convertUMaccount
as
begin
merge into t_agent_agentinfo a
using (select agentid,ccid,vdnid,umaccount from T_AGENT_IMPORTUM) b
on (a.agentid = b.agentid and a.ccid = b.ccid)
when matched then update set a.umaccount = nvl(b.umaccount,a.umaccount)
when not matched then insert(a.agentid,a.ccid,a.companyid,a.umaccount) values(b.agentid,b.ccid,b.vdnid,b.umaccount);
delete from T_AGENT_IMPORTUM;
commit;
exception
when others then
rollback;
dbms_output.put_line(sqlerrm);
end;