Listing 1: Defining and Accessing a Multilevel Collection


1  DECLARE
 2     TYPE bunch_of_pets_t IS TABLE OF pet_t INDEX BY BINARY_INTEGER;
 3     my_pets   bunch_of_pets_t;
 4  BEGIN

 5     my_pets (1) :=
 6           pet_t (100, 'Mercury',
 7              vet_visits_t (
 8                 vet_visit_t ('01-Jan-2001', 'Clip wings'),
 9                 vet_visit_t ('01-Apr-2002', 'Check cholesterol'))
10           );

11     DBMS_OUTPUT.PUT_LINE (my_pets (1).name);
12     DBMS_OUTPUT.PUT_LINE (my_pets (1).petcare (2).reason);
13     DBMS_OUTPUT.put_line (my_pets.COUNT);
14 DBMS_OUTPUT.put_line (my_pets(1).petcare.LAST);
15 END;