DECLARE
TYPE bunch_of_pets_t IS TABLE OF pet_t
INDEX BY PLS_INTEGER;
my_pets bunch_of_pets_t;
l_first_pet pet_t;
l_last_visit vet_visit_t;
BEGIN
my_pets (1) :=
pet_t (
100
, 'Mercury'
, 'African Grey Parrot'
, vet_visit_lists_t (
vet_visit_t ('01-Jan-2001', 'Clip wings')
, vet_visit_t ('01-Apr-2002'
, 'Check cholesterol')));
DBMS_OUTPUT.put_line (my_pets (my_pets.FIRST).name);
DBMS_OUTPUT.put_line (
my_pets (my_pets.FIRST).petcare (
my_pets (my_pets.FIRST).petcare.LAST).reason);
DBMS_OUTPUT.put_line (my_pets.COUNT);
DBMS_OUTPUT.put_line (
my_pets (my_pets.FIRST).petcare.FIRST);
/* Hiding the details: declare local variables to hold "intermediate"
structures, making the code a bit more readable */
l_first_pet := my_pets (my_pets.FIRST);
l_last_visit :=
l_first_pet.petcare (l_first_pet.petcare.LAST);
DBMS_OUTPUT.put_line (l_last_visit.reason);
END;