Table of type : Table of Type « Collections « Oracle PL/SQL Tutorial






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>
SQL>
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>
SQL>
SQL> drop table employee;

Table dropped.

SQL>
SQL>








26.26.Table of Type
26.26.1.Table of type
26.26.2.Use of PL/SQL tables of types
26.26.3.Use LOOP to output all elements in a table collection
26.26.4.Forall in value of table of type
26.26.5.Table of user-defined types
26.26.6.Select user-defined type into table collection of user-defined types