我想使用DELETE Collection
Method 删除集合中的一些元素,例如:
create or replace procedure testloop3 (clearaaa out nestedtable) as
type nestedtable is table of varchar2(255);
reply_ref_messageIds nestedtable;
getDelete_messageIds nestedtable;
begin
select distinct r.messagebox_id bulk collect into reply_ref_messageIds from reply r;
select m.id bulk collect into getDelete_messageIds from messagebox m;
getDelete_messageIds.delete(2);
getDelete_messageIds.delete(4);
getDelete_messageIds.delete(7);
getDelete_messageIds.delete(11);
getDelete_messageIds.delete(13);
for i in getDelete_messageIds.FIRST .. getDelete_messageIds.LAST loop
dbms_output.put_line(i);
end loop;
for i in 5 .. 12 loop
dbms_output.put_line(i);
end loop;
end;
然后我用 plsql dev 调试这个过程
-- Created on 2013/4/4 by THINKPAD
declare
-- Local variables here
aa nestedtable;
begin
-- Test statements here
testloop3(aa);
end;
我得到了getDelete_messageIds
删除前的索引,它们是 1 到 15。
但是:当我调试getDelete_messageIds.delete(2);
它时,它会删除索引 1 和 2 ......我无法解释为什么。
然后当我调试下一条语句时getDelete_messageIds.delete(4);
,它会删除索引 3 和 4。然后getDelete_messageIds.delete(7);
只删除索引 7 ......
我无法理解......