以下のコードでは、最初の挿入ステートメントは、
insert into customer_master select max(customerid)+1,customer_name from customer_master
where customer_name not in (select customername from customer_master);
これに対して null 値の挿入エラーが発生しています。はいそうです。
しかし、ブロックのステートメントの下で実行が停止しています。
insert into customer_account_mapping select customerid,upper(pcd(i)),upper(acd(i)),cost from customer_master where customername=customer_name and concat(upper(pcd(i)),upper(acd(i))) not in (select concat(upper(pcode),upper(acode)) from customer_account_mapping);
insert into user_permissions select distinct user_id,sales_person_name,sales_mgr_name,upper(pcd(i)),upper(acd(i)) from user_permissions where sales_person_name=sales_person and concat(upper(pcd(i)),upper(acd(i))) not in (select concat(upper(pcode),upper(acode)) from user_permissions) and rownum<2 ;
完全なコードを以下に示します。
create or replace
procedure dashboard_addtion
(customer_name varchar2,pcd parray,acd aarray,sales_person varchar2,cost number)
IS
begin
insert into customer_master select max(customerid)+1,customer_name from customer_master
where customer_name not in (select customername from customer_master);
for i in 1..acd.count loop
insert into customer_account_mapping select customerid,upper(pcd(i)),upper(acd(i)),cost from customer_master where customername=customer_name and concat(upper(pcd(i)),upper(acd(i))) not in (select concat(upper(pcode),upper(acode)) from customer_account_mapping);
insert into user_permissions select distinct user_id,sales_person_name,sales_mgr_name,upper(pcd(i)),upper(acd(i)) from user_permissions where sales_person_name=sales_person and concat(upper(pcd(i)),upper(acd(i))) not in (select concat(upper(pcode),upper(acode)) from user_permissions) and rownum<2 ;
commit;
end loop;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE (SQLERRM);
end;