我需要加快将记录插入映射表的过程。
我使用的程序有签名:
InsertDocsToFolder as
procedure this(p_folderid in number, p_docs in out nocopy DocList)
DocList定义为
type DocList is table of int index by integer;
过程的核心插入记录如下,t_docs是主文档表,t_mapping是将p_folderid映射到p_docs的表:
forall i in 1..p_docs.count save exceptions
insert into t_mapping select p_folderid, p_docs(i) from t_docs D where D.docid = p_docs(i);
commit;
我想我应该能够用一个SQL语句替换forall循环。有谁能建议更快的技术?由于p_docs是一个表类型,我可以直接将它加入t_docs吗?
答案 0 :(得分:3)
您只能在SQL中使用在服务器上创建的集合类型(“创建类型...”)。所以如果你这样做了:
create type DocList is table of int;
然后你可以这样选择:
insert into t_mapping
select p_folderid, column_value
from table (cast (t_docs as DocList));