Mega Code Archive

 
Categories / Oracle PLSQL Tutorial / Collections
 

Table of type

SQL> SQL> create table employee (   2  id                             number                         not null,   3  employee_type_id               number                         not null,   4  external_id                    varchar2(30)                   not null,   5  first_name                     varchar2(30)                   not null,   6  middle_name                    varchar2(30),   7  last_name                      varchar2(30)                   not null,   8  name                           varchar2(100)                  not null,   9  birth_date                     date                           not null,  10  gender_id                      number                         not null ); Table created. SQL> SQL> declare   2  TYPE name_table is table of employee.name%TYPE index by binary_integer;   3  TYPE name_record is record ( dim2 name_table );   4  TYPE dim1 is table of name_record index by binary_integer;   5  t_dim1 dim1;   6  begin   7    t_dim1(1).dim2(1) := 'AAA';   8    t_dim1(1).dim2(2) := 'BBB';   9  10    t_dim1(2).dim2(1) := 'CCC';  11    t_dim1(2).dim2(2) := 'DDD';  12  13    dbms_output.put_line (t_dim1(1).dim2(1));  14    dbms_output.put_line (t_dim1(1).dim2(2));  15    dbms_output.put_line (t_dim1(2).dim2(1));  16    dbms_output.put_line (t_dim1(2).dim2(2));  17  end;  18  / AAA BBB CCC DDD PL/SQL procedure successfully completed. SQL> SQL> drop table employee; Table dropped. SQL>