因為高層決議要全面更改Employee Number的格式,所以寫了可以批次更改Employee Number。
記錄下來,也許哪天又想到要更改Employee Number時就可以直接套用了。
declare
cursor cur1 is
--tmp_ccc是暫存的表格,有兩個欄位
--a為原來的employee_number,b為新的employee_number
select * from tmp_ccc;
r1 cur1%rowtype;
v_check number :=0;
v_a number :=0;
begin
for r1 in cur1 loop
--確認Employee Number是否存在
select count(1) into v_a from per_all_people_f where employee_number=r1.a ;
if v_a=1 then
v_check := v_check +1;
--直接修改per_all_people_f
update per_all_people_f set employee_number=r1.b where employee_number=r1.a ;
dbms_output.put_line(v_check);
end if;
end loop;
end;