|
Re: indexed variables in PL/SQL eg. i1,i2,i3 [message #4021 is a reply to message #4018] |
Sun, 03 November 2002 16:08 |
N
Messages: 26 Registered: April 2002
|
Junior Member |
|
|
PL/SQL Tables
Like an array, a PL/SQL table is an ordered collection of elements of the same type. Each element has a unique index number that determines its position in the ordered collection. But, unlike an array, a PL/SQL table is unbounded. So, its size can increase dynamically. Also, it does not require consecutive index numbers. So, it can be indexed by any series of integers.
PL/SQL tables help you move bulk data. They can store columns or rows of Oracle data, and they can be passed as parameters. So, PL/SQL tables make it easy to move collections of data into and out of database tables or between client-side applications and stored subprograms.
You can use a cursor FOR loop to fetch an entire column or table of Oracle data into a PL/SQL table. In the following example, you fetch a table of data into the PL/SQL table dept_tab:
DECLARE
TYPE DeptTabTyp IS TABLE OF dept%ROWTYPE
INDEX BY BINARY_INTEGER;
dept_tab DeptTabTyp;
n BINARY_INTEGER := 0;
BEGIN
FOR dept_rec IN (SELECT * FROM dept) LOOP
n := n + 1;
dept_tab(n) := dept_rec;
END LOOP;
...
END;
|
|
|