The “from-sql routine” and the “to-sql routine” create a mapping between a UDT and a predefined type. This pre-defined type is called the external type of a UDT. A client application only deals with the external type; it does not deal with UDT value directly.
External Type Example
- UDT named FULLNAME exists
- The external type associated with FULLNAME is VARCHAR(46)
Then, during an retrieve of FULLNAME values, the database converts the values from FULLNAME values to VARCHAR(46) values by invoking the “from-sql routine” associated with the FULLNAME UDT.
Similarly, when values are provided by the client for insert into a FULLNAME UDT, the client must provide values in the same way it would provide values for a VARCHAR(46) field. The database will convert the values from VARCHAR(46) to FULLNAME values using the “to-sql routine” associated with the FULLNAME UDT.