Can I slice a PL/SQL collection?
I've got a PL/SQL VArray that I'm filling with a BULK COLLECT query like this:
SE开发者_运维技巧LECT 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?
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.
精彩评论