Oracle PL/SQL - RECORD Type with Varray Field

Introduction

The following code defines a VARRAY type, full_name, and a RECORD type, contact.

The type contact has a field of type full_name.

Demo

SQL>
SQL>--   w w  w. j  a v a2s .c  o  m
SQL> DECLARE
  2    TYPE full_name IS VARRAY(2) OF VARCHAR2(20);
  3    TYPE contact IS RECORD (
  4      name  full_name := full_name('John', 'Smith'),  -- varray field
  5      phone emp.phone_number%TYPE
  6    );
  7
  8    friend contact;
  9  BEGIN
 10    friend.phone := '1-650-555-1234';
 11
 12    DBMS_OUTPUT.PUT_LINE (
 13      friend.name(1) || ' ' ||
 14      friend.name(2) || ', ' ||
 15      friend.phone
 16    );
 17  END;
 18  /

SQL>

A RECORD type defined in a package specification is incompatible with an identically defined local RECORD type.

Related Topic