LIST(e) data type
The LIST data type is a collection type that can store ordered non-NULL elements of the same SQL data type.
The LIST data type supports, but does not require, duplicate element values. The elements of a LIST data type have ordinal positions. The LIST object must have a first element, which can be followed by a second element, and so on.
For unordered collection data types that do not support ordinal positions, see MULTISET(e) data type and SET(e) data type. For complex data types that can store a set of values that includes different SQL data types, see ROW Data Types.
No more than 97 columns of the same table can be declared as LIST data types. (The same restriction applies to SET and MULTISET collection types.)
By default, the database server inserts new elements into a LIST object at the end of the set of elements. To support the ordinal position of a LIST, the INSERT statement provides the AT clause. This clause allows you to specify the position at which you want to insert a LIST element value. For more information, see the INSERT statement in the Informix® Guide to SQL: Syntax.
LIST(element_type NOT NULL)
- A built-in type, except SERIAL, SERIAL8, BIGSERIAL, BYTE, and TEXT
- A DISTINCT type
- An unnamed or named ROW type
- Another collection type
- An opaque type
You must specify the NOT NULL constraint for LIST elements. No other constraints are valid for LIST columns. For more information about the syntax of the LIST data type, see the Informix® Guide to SQL: Syntax.
- After the IN predicate in the WHERE clause of a SELECT statement to search for matching LIST values
- As an argument to the CARDINALITY or mi_collection_card( ) function to determine the number of elements in a LIST column
You cannot use LIST values as arguments to an aggregate function such as AVG, MAX, MIN, or SUM.
( )
) in data type declarations to delimit the
set of elements of a LIST data type: CREATE FUNCTION update_nums( list1 LIST (ROW (a VARCHAR(10),
b VARCHAR(10),
c INT) NOT NULL ));
In
SQL expressions that include literal LIST values, however, you must
use braces ( { }
) to delimit the set of elements
of a LIST object, as in the examples that follow.LIST{"blue", "green", "yellow"}
LIST{"yellow", "blue", "green"}
LIST{"blue", "green", "yellow"}