问题描述
procedure insert(serno in number,username in varchar2)
is
childs_all path_child_tab:=path_childs_Tab();
childs_of_childs path_child_tab:=path_childs_Tab();
v_cntr number;
begin
v_serno:=serno;
childs_all:=path_childs_serno(v_Serno) --return table with the example below the 6 here
v_cntr:=childs_all.last+1;
FOR child IN childs_all.first..childs_all.last loop
childs_of_childs:=path_childs_serno(childs_all(child).serno);-- return table with the example below the 5
FOR R IN childs_of_childs.FirsT..childs_of_childs.LAST LOOP
childs_all.extend;
childs_all(v_cntr):=path_childs_row(childs_of_childs(r).serno); -- here I extend the 5 in first table of loop but never go through the first loop to take his child(4)
v_cntr:=v_cntr+1;
END LOOP;
FOR X IN childs_all.first..childs_all.last loop
INSERT_SERNO_IN_TABLE(childs_all(x).serno,username); -- procedure to insert all the serno in other table
end loop;
end loop;
end;
带有 sernos 的表格示例
4-> 有父级 5
5 -> 有父级 6
6 -> 有父级 2
2-> 有父级 1
1 -> 有父 0
问题
当我用 2 调用该过程时,我只得到 5 和 6,因为我得到了 childs_all 表中 2(6) 的子项和 childs_of_childs 表中 6 (5) 的子项,并且它们扩展到 childs_all 正确,但它们没有通过 For 循环,所以 5 在第一个 for 循环中没有通过 path_childs_serno 并取 4 并在 childs_all 中扩展它,所以在我的结果中会有 4,5,6 有没有办法做到这一点?
希望你明白我想做什么
提前致谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)