create or replace procedure chushihua_code11 is
v_code t_bas_sales_department.code%type;
v_fid t_bas_businessdept.fid%type;
cursor cur_track is
select distinct bd.code fcode, bd.fid fid
from (select distinct b.fid, d.code, d.name
from t_bas_businessdept b
join t_bas_sales_department d
on b.fname_l2 = d.name) bd
join t_web_customerinfo_0524 t1
on bd.fid = t1.fservdeptid;
begin
open cur_track;
loop
fetch cur_track
into v_code, v_fid;
exit when cur_track%notfound;
update t_web_customerinfo_0524 t1
set t1.fservdeptid = v_code
where t1.fservdeptid = v_fid;
end loop;
--commit;
end chushihua_code11;
/