我正在研究一个基于某些资格分配指标的plsql脚本。我通过尝试使用2个嵌套for循环来完成此操作。但是,当我尝试执行时,我在第2行得到错误“无效的SQL语句”。我一遍又一遍地查看它,找不到任何问题。任何帮助表示赞赏。
begin
for rec in (select prgm_id, (prgm_cntl_pct * cntl_count) as cntl from tmp_prgm_cntl) loop
for rec2 in (select * from tmp_cust_pop tcp where tcp.prgm_id = rec.prgm_id and rownum <= rec.cntl order by tcp.rand_num) loop
insert into fact_cust_trgt_pop (fact_cust_trgt_pop_id, stg_prgm_cust_trgt_pop_id, cust_nbr, cust_id,
prgm_id, prgm_name, prgm_cntl_ind, cmpg_cntl_ind, cust_open_dt, cre_dt, updt_dt)
(select
(select dmbs_random.value(1,200)from dual) as fact_cust_trgt_pop_id,
rec2.stg_cust_trgt_pop_id,
sctp.cust_nbr,
sctp.cust_id,
sctp.prgm_id,
sctp.prgm_name,
1 as prgm_cntl_ind,
(select (dmbs_random.value(0,2)) case when <=1 then 'a' else 'b' as cmpg_cntl_ind end from dual) as cmpg_cntl_ind,
sctp.prgm_cust_open_dt,
sctp.cre_dt,
sctp.updt_dt
from
stg_cust_trgt_pop sctp
join sc45437.stg_cust_trgt_pop sctp
on
sctp.stg_cust_trgt_pop_id = tcp.stg_cust_trgt_pop_id);
end loop;
end loop;
end;