我可以对 PL/SQL 集合进行切片吗?
我有一个 PL/SQL VArray,我正在用这样的 BULK COLLECT 查询填充它:
SELECT id
BULK COLLECT INTO myarray
FROM aTable
现在我想将该集合的一个切片传递到另一个集合中,如下所示:
newarray := myarray(2..5)
这应该传递元素 2,3 ,4 和 5 从 myarray 到 newarray。
我可以编写一个循环并复制元素,但是有没有更紧凑的方法来做到这一点?
I've got a PL/SQL VArray that I'm filling with a BULK COLLECT query like this:
SELECT id
BULK COLLECT INTO myarray
FROM aTable
Now I'd like to pass a slice of this collection into another collection, something like this:
newarray := myarray(2..5)
This should pass the elements 2,3,4 and 5 from myarray to newarray.
I could write a loop and copy the elements, but is there a more compact way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一般来说,您不想这样做。您的内存中有一个很大的集合,现在您想要为其创建一个副本。这将使用更多的内存。通常在这种情况下,您传递整个集合(通过引用,而不是值),并提供开始和停止索引。让其他函数只处理指定的范围。
Generally, you don't want to do this. You have a large collection in memory, and now you want to make a copy of it. That would use even more memory. Usually in cases like this you pass the entire collection around (by reference, not value) and also provide a start and stop index. Leave it to the other functions to only process the range specified.