Implicit and explicit casts

You can specify whether a cast is called for implicit conversions. Implicit conversions allow the database server to use the cast when it is not called explicitly in an SQL statement.

For example, if you call the Plus() function with a DOLLAR argument, the database server searches for an implicit cast from DOLLAR to a data type for which the Plus() function is defined. If an implicit cast exists, the database server calls the conversion function and then calls the Plus() function without error. If no cast is specified with implicit conversion, the Plus() function call results in an error message from the database server.

In this example, you create an implicit cast from DOLLAR to DOUBLE PRECISION to permit the database server to execute all functions defined for DOUBLE PRECISION on DOLLAR values. However, if you define a cast from DOLLAR to INTEGER, you do not want that cast to be implicit, because the conversion function truncates dollar values, resulting in inaccurate results.