Oracle PL/SQL - Nested Tables of Associative Arrays and Varrays of Strings

Introduction

In the following code, NestedNumberTable is an associative array of associative arrays, and table_type_2 is a nested table of varrays of strings.

Demo

SQL>
SQL> DECLARE-- from  www.  ja v  a 2 s  .  com
  2    TYPE NumberTable IS TABLE OF INTEGER INDEX BY PLS_INTEGER;
  3    v4 NumberTable;
  4    v5 NumberTable;
  5
  6    TYPE NestedNumberTable IS TABLE OF NumberTable INDEX BY PLS_INTEGER; 
  7    v2 NestedNumberTable;     --  associative arrays
  8
  9    TYPE va1 IS VARRAY(10) OF VARCHAR2(20); 
 10    v1 va1 := va1('myname', 'world');
 11
 12    TYPE table_type_2 IS TABLE OF va1 INDEX BY PLS_INTEGER; 
 13    v3 table_type_2;
 14
 15  BEGIN
 16    v4(1)   := 34;   
 17    v4(2)   := 46456;
 18    v4(456) := 343;
 19
 20    v2(23) := v4;  
 21
 22    v3(34) := va1(33, 456, 656, 343); 
 23
 24    v2(35) := v5;     
 25    v2(35)(2) := 78;
 26  END;
 27  /

PL/SQL procedure successfully completed.

SQL>

Related Topic