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?
Description PL/SQL doesn't offer native support for multi-dimensional arrays, as you will find in other programming languages. You can, however, emulate these structures using nested collections.
A collection is an ordered group of elements having the same data type. Each element is identified by a unique subscript that represents its position in the collection. PL/SQL provides three collection types − Index-by tables or Associative array.
Answer : C. Q 2 - Which of the following is not true about the PL/SQL language? A - PL/SQL's general syntax is based on that of ADA and Pascal programming language. B - Apart from Oracle, PL/SQL is available in TimesTen in-memory database and IBM DB2.
Using PL/SQL Collections with SQL Statements. Collections let you manipulate complex datatypes within PL/SQL. Your program can compute subscripts to process specific elements in memory, and use SQL to store the results in database tables.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With