Home |
Previous Page | Next Page Data Types > Data Type Casting and Conversion >
The database server uses the following rules to determine
which cast to apply in a particular situation:
- To compare two built-in types, the database server automatically
invokes the appropriate built-in casts.
- The database server applies only one implicit cast per operand.
If two or more casts are needed to convert the operand to the desired
type, the user must explicitly invoke the additional casts.
In the following example, the literal value 5.55 is implicitly cast to DECIMAL, and
is then explicitly cast to MONEY, and finally
to yen:
CREATE DISTINCT TYPE yen AS MONEY
. . .
INSERT INTO currency_tab
VALUES (5.55::MONEY::yen)
- To compare a distinct type to its source
type, the user must explicitly cast one type to the other.
- To compare a distinct type to a type
other than its source, the database server looks for an implicit
cast between the source type and the desired type.
If neither cast is registered, the user must invoke an explicit
cast between the distinct type and the
desired type. If this cast is not registered, the database server
automatically invokes a cast from the source type to the desired type.
If none of these casts is defined, the comparison fails.
- To compare an opaque type to a built-in
type, the user must explicitly cast the opaque type to a data type
that the database server understands (such as LVARCHAR, SENDRECV, IMPEX,
or IMPEXBIN). The database server then invokes
built-in casts to convert the results to the desired built-in type.
- To compare two opaque types, the user must explicitly cast one
opaque type to a form that the database server understands (such
as LVARCHAR, SENDRECV, IMPEX,
or IMPEXBIN) and then explicitly cast this
type to the second opaque type.
For information about casting and the IMPEX, IMPEXBIN, LVARCHAR, and SENDRECV types,
see IBM Informix: User-Defined Routines and Data Types Developer's Guide.
Home |
[ Top of Page | Previous Page | Next Page | Contents |
Index ]