SQL>
SQL> DECLARE
2 TYPE t_MajorTable IS TABLE OF VARCHAR(20) INDEX BY BINARY_INTEGER;
3 v_Majors t_MajorTable;
4 v_Index BINARY_INTEGER;
5 BEGIN
6 -- Insert values into the table.
7 v_Majors(-7) := 'A';
8 v_Majors(4) := 'B';
9 v_Majors(5) := 'C';
10
11 -- Loop over all the rows in the table, and insert them into
12 -- temp_table.
13 v_Index := v_Majors.FIRST;
14 LOOP
15 DBMS_OUTPUT.put_line(v_Index||' ' || v_Majors(v_Index));
16 EXIT WHEN v_Index = v_Majors.LAST;
17 v_Index := v_Majors.NEXT(v_Index);
18 END LOOP;
19 END;
20 /
-7 A
4 B
5 C
PL/SQL procedure successfully completed.
SQL>
|