A UDT can exist only on the Teradata Database server. Each UDT has an associated from-sql routine and to-sql routine. The from-sql routine generates a predefined type value from a UDT. It is automatically invoked when a UDT is exported from the Teradata Database server to a client system. The to-sql routine constructs a UDT value from a predefined type value. It is automatically invoked when importing values from a client system into a UDT on the Teradata Database server. The from-sql routine and to-sql routine create a mapping between a UDT and a predefined type. The predefined type is called the external type of a UDT. A client application only deals with the external type; it does not deal directly with the UDT value.
For example, if a UDT named FULLNAME exists and the external type associated with FULLNAME is VARCHAR(46), then during an export of FULLNAME values, the Teradata Database server converts the values from FULLNAME values to VARCHAR(46) values by invoking the from-sql routine associated with the FULLNAME UDT. As a result, the client should expect to receive the data in the same format as it receives VARCHAR(46) values.
Similarly, when values are provided by the client for import into a FULLNAME UDT, the client should provide values like it would provide values for a VARCHAR(46) field, and the Teradata Database server then converts the values from VARCHAR(46) to FULLNAME values by invoking the to-sql routine associated with the FULLNAME UDT.