When you compare or manipulate data of a distinct type and its source type, you must explicitly cast one type to the other in the following situations:
For example, suppose you create a distinct type, dist_type, that is based on the NUMERIC data type. You then create a table with two columns, one of type dist_type and one of type NUMERIC.
CREATE DISTINCT TYPE dist_type AS NUMERIC; CREATE TABLE t(col1 dist_type, col2 NUMERIC);
To directly compare the distinct type and its source type or assign a value of the source type to a column of the distinct type, you must cast one type to the other, as the following examples show:
INSERT INTO tab (col1) VALUES (3.5::dist_type); SELECT col1, col2 FROM t WHERE (col1::NUMERIC) > col2; SELECT col1, col2, (col1 + col2::dist_type) sum_col FROM tab;
Related statements: CREATE CAST, CREATE FUNCTION, CREATE OPAQUE TYPE, CREATE ROW TYPE , DROP TYPE , and DROP ROW TYPE
For information and examples that show how to use and cast distinct types, see the IBM Informix Guide to SQL: Tutorial.
For more information on when you might create a distinct type, see IBM Informix User-Defined Routines and Data Types Developer's Guide.