Reference varray.count in for loop
SQL> CREATE OR REPLACE TYPE unitType AS VARRAY(13) OF VARCHAR2(5 CHAR);
2 /
Type created.
SQL> CREATE OR REPLACE TYPE categoryType AS VARRAY(4) OF VARCHAR2(8 CHAR);
2 /
Type created.
SQL> CREATE OR REPLACE TYPE charArrayType AS TABLE OF VARCHAR2(17 CHAR);
2 /
Type created.
SQL>
SQL> DECLARE
2 counter INTEGER := 0;
3
4 suits categoryType :=categoryType('A','B','C','D');
5 units unitType :=unitType('1','2','3','4','Five','Six','Seven');
6
7 charArray charArrayType := charArrayType();
8 BEGIN
9
10 FOR i IN 1..suits.COUNT LOOP
11 FOR j IN 1..units.COUNT LOOP
12 counter := counter + 1;
13 charArray.EXTEND;
14 charArray(counter) := units(j)||' of '||suits(i);
15 END LOOP;
16 END LOOP;
17
18 END;
19 /
PL/SQL procedure successfully completed.
Related examples in the same category