DROP CAST statement

Use the DROP CAST statement to remove an existing cast from the database.

This statement is an extension to the ANSI/ISO standard for SQL.


1  DROP CAST? IF EXISTS  ( source_type AS target_type )
Element Description Restrictions Syntax
source_type Data type that the cast accepts as input Must exist Identifier; Data Type
target_type Data type returned by the cast Must exist Identifier; Data Type


You must be owner of the cast or have the DBA privilege to use DROP CAST. Dropping a cast removes its definition from the syscasts system catalog table, so the cast cannot be invoked explicitly or implicitly. Dropping a cast has no effect on the user-defined function associated with the cast. Use the DROP FUNCTION statement to remove the user-defined function from the database.
Warning: Do not drop built-in casts, which user informix owns. These are required for automatic conversions between built-in data types.

A cast defined on a given data type can also be used on any DISTINCT types created from that source type. If you drop the cast, you can no longer invoke it for the DISTINCT types, but dropping a cast that is defined for a DISTINCT type has no effect on casts for its source type. When you create a DISTINCT type, the database server automatically defines an explicit cast from the DISTINCT type to its source type and another explicit cast from the source type to the DISTINCT type. When you drop the DISTINCT type, the database server automatically drops these two casts.

If you include the optional IF EXISTS keywords, the database server takes no action (rather than sending an error to the application) if no cast between the two specified data types is registered in the current database.


A cast (like this one in the superstores_demo database) can be dropped with the DROP CAST statement:
DROP CAST (decimal(5,5) AS percent);
Details of existing casts can be found in the syscasts system catalog table the following SQL:
SELECT routine_name, class, argument_type, result_type FROM Syscasts;