【发布时间】:2021-08-16 02:35:12
【问题描述】:
我正在编写和 pl/sql 程序并得到错误为 PLS-00642:SQL 语句中不允许本地集合类型和 PL/SQL: ORA-00947: 没有足够的值
首先我调用了一个游标并迭代游标,然后再次获取记录,错误即将到来。
declare
type t1 is record (
msisdn varchar2(20),
imsi varchar2(14),
date_time date,
mml_cmd varchar2(50),
cmd_executed varchar2(2500),
myrank number);
type t2 is table of t1;
l_k t2;
type t3 is table of hlr_agent_logs%rowtype;
l_tab t3;
cursor c1 is select * from hlr_agent_logs where date_time>trunc(sysdate-2) and mml_cmd='ADD USER' and cmd_executed like '%Profile=3%' order by date_time;
begin
open c1;
loop
fetch c1 bulk collect into l_tab limit 500;
exit when l_tab.count=0;
for i in l_tab.first .. l_tab.last loop
begin
select msisdn, imsi, date_time , mml_cmd,cmd_executed,rank() over (partition by imsi order by date_time asc) as myrank into l_k from hlr_agent_logs
where substr(msisdn,3)=l_tab(i).msisdn and imsi=l_tab(i).imsi and date_time>=l_tab(i).date_time;
for k in l_k.first..l_k.last loop
dbms_output.put_line(l_k(k).msisdn);
end loop;
exception when no_data_found then
null;
end;
end loop;
close c1;
end loop;
end;
/
【问题讨论】:
-
能否提供表hlr_agent_logs的结构??