An anonymous PL/SQL procedure to demonstrate the use of PL/SQL records : Table of Record « 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> declare
  2      TYPE name_record is record (
  3      first_name                            employee.first_name%TYPE,
  4      middle_name                           employee.middle_name%TYPE,
  5      last_name                             employee.last_name%TYPE );
  6      TYPE name_table is table of name_record index by binary_integer;
  7      t_name                                name_table;
  8  begin
  9   t_name(1).first_name  := 'JOHN';
 10   t_name(1).last_name   := 'DOE';
 11   t_name(2).first_name  := 'JANE';
 12   t_name(2).last_name   := 'DOE';
 13
 14   dbms_output.put_line(t_name(1).last_name||', '||t_name(1).first_name);
 15   dbms_output.put_line(t_name(2).last_name||', '||t_name(2).first_name);
 16  end;
 17  /
DOE, JOHN
DOE, JANE

PL/SQL procedure successfully completed.

SQL>
SQL>
SQL> drop table employee;

Table dropped.

SQL>








26.24.Table of Record
26.24.1.Table collection of records
26.24.2.Defining an Index-by table of records
26.24.3.Bulk DML with table of records
26.24.4.An anonymous PL/SQL procedure to demonstrate the use of PL/SQL records