Select from a collection
This section describes how to query columns that are defined on collection types. A collection type is a complex data type in which each collection value contains a group of elements of the same data type. For a detailed description of collection data types, see the IBM® Informix® Database Design and Implementation Guide. For information about how to access the individual elements that a collection contains, see Handle collections in SELECT statements.
CREATE TABLE manager
(
mgr_name VARCHAR(30),
department VARCHAR(12),
direct_reports SET(VARCHAR(30) NOT NULL),
projects LIST(ROW(pro_name VARCHAR(15),
pro_members SET(VARCHAR(20) NOT NULL)
) NOT NULL)
)
SELECT department, direct_reports FROM manager
department marketing
direct_reports SET {Smith, Waters, Adams, Davis, Kurasawa}
department engineering
ddirect_reports SET {Joshi, Davis, Smith, Waters, Fosmire, Evans, Jones}
department publications
direct_reports SET {Walker, Fremont, Porat, Johnson}
department accounting
direct_reports SET {Baker, Freeman, Jacobs}
⋮
The output of a query on a collection type always includes the type constructor that specifies whether the collection is a SET, MULTISET, or LIST. For example, in the result, the SET constructor precedes the elements of each collection. Braces ({}) demarcate the elements of a collection; commas separate individual elements of a collection.