Retrieving structured type attributes
To explicitly access individual attributes of an object, invoke the Db2® built-in observer methods on those attributes. Using the observer methods, you can retrieve the attributes individually rather than treating the object as a single value.
About this task
The following example accesses data in the
Address
column
by invoking the observer methods on Address_t
, the
defined static type for the Address
column: SELECT Name, Dept, Address..street, Address..number, Address..city,
Address..state
FROM Employee
WHERE Salary > 20000;
Note: Db2 enables
you to invoke methods that take no parameters using either
type-name..method-name()
or type-name..method-name
,
where type-name represents the name of the structured
type, and attribute-name represents the name of
the method that takes no parameters.You can also use observer
methods to select each attribute into a host variable, as follows:
SELECT Name, Dept, Address..street, Address..number, Address..city,
Address..state
INTO :name, :dept, :street, :number, :city, :state
FROM Employee
WHERE Empno = '000250';