Observer methods for structured types

An observer method exists for each attribute of an object. If the method for an attribute receives an object of the expected type or subtype, the method returns the value of the attribute for that object.

The observer method Db2® creates for the attribute age of the type Person_t, for example, has the following format:

   ALTER TYPE Person_t
      ADD METHOD AGE()
      RETURNS INTEGER;

To invoke a method on a structured type, use the method invocation operator: '..'.

The following example demonstrates the use of observer methods for the Person_t type:
  CREATE FUNCTION MailingAddress (p Person_t)
    RETURNS VARCHAR(40)
    RETURN p..name() || ' ' || p..address()
In this function, the name column and address column from a Person_t instance are retrieved via their observer methods and concatenated into a single string to form a mailing address.