For best practice, pair transform group functionality with the equivalent cast functionality. See CREATE TRANSFORM and REPLACE TRANSFORM. Create parallel functionalities for the two conversion types, for example:
Cast Functionality | Equivalent Transform Functionality |
---|---|
External predefined data type to UDT cast | External predefined data type to UDT tosql transform |
UDT to external predefined data type cast | UDT to external predefined data type fromsql transform |
This is highly recommended if you want to use a UDT in the same way you would use any other data type. Especially in regard to load utilities and the USING row descriptor, it is recommended that the type developer back up their tosql and fromsql functionality with equivalent external type (predefined) to UDT and UDT to external type (predefined) implicit casts, respectfully.
For equivalence, you can reference the same external routines in the CREATE TRANSFORM and CREATE CAST statements for the same UDT.
The following table describes the differences for distinct and structured UDTs:
FOR this kind of UDT … | You must do the following work to create parallel casting and transform functionality… |
---|---|
distinct | none if you plan to use the system-generated casts and transforms. However, if you decide to write your own external cast and transform routines for the UDT, you must create the parallel cast and transform functionalities explicitly using the CREATE CAST and CREATE TRANSFORM statements, respectively. |
structured | create the necessary casts and transforms explicitly, using the same external routines for both. |
For more information, see CREATE CAST and REPLACE CAST and CREATE TRANSFORM and REPLACE TRANSFORM .