declare
l_cust_id number(10) := 0;
l_person_id number(10) := 0;
begin
DBMS_OUTPUT.ENABLE(buffer_size => null); --表示輸出buffer不受限制
for lr in (SELECT temp.customer_name, temp.assign_persion_name
from CUSTOMER_ASSIGN_TEMP temp) loop
--dbms_output.put_line(lr.customer_name||'|'||lr.assign_persion_name);
begin
select hz.party_id
into l_cust_id
from hz_parties hz
where trim(hz.party_name) = trim(lr.customer_name)
and rownum = 1;
update CUSTOMER_ASSIGN_TEMP cust
set cust.cust_party_id = l_cust_id where trim(cust.customer_name)=trim(lr.customer_name);
exception
when No_data_found then
dbms_output.put_line(trim(lr.customer_name) || '-客戶名稱不正確');
end;
begin
select emp.PERSON_ID
into l_person_id
from web_employees_v emp
where emp.CHINESE_NAME = lr.assign_persion_name
and rownum = 1;
update CUSTOMER_ASSIGN_TEMP custp
set custp.assign_persion_id = l_person_id where trim(custp.customer_name)=trim(lr.customer_name);
exception
when No_data_found then
dbms_output.put_line(lr.assign_persion_name || '-人員名稱不正確');
end;
commit;
end loop;
end;
----調用
declare
l_code varchar2(1000);
begin
pro_syn_customer_ecp('Y',l_code);
dbms_output.put_line(l_code);
end;