Understanding SQL & Java Together: A Guide to SQLJ, JDBC, and Related Technologies

The term "user-defined type" may seem to be pretty much self-explanatory, but we'll try to expand on it anyway. The use of "type" is meant to imply "data type," that is, a data type that can be the type of some piece of data in the environment under discussion. In an SQL environment, this would normally be the data type of a column in a table, of an SQL variable in an SQL-invoked routine written in SQL, or of a parameter to an externally invoked SQL routine (which is nothing but a fancy name for the implicit procedures generated for embedded SQL statements). The inclusion of the phrase "user-defined" suggests that the type isn't built into the database system but is defined in some other manner. Before we examine user-defined types specifically, let's look at the history that brought us to this discussion.
SQL database systems have always had a selection of built-in data types that are available for use in applications. They range from types specified in the SQL standard (such as INTEGER and SMALLINT, CHARACTER and CHARACTER VARYING, and DATE, TIME, and TIMESTAMP) to proprietary types defined by individual database system products (such as Sybase's SMALLMONEY and IMAGE types or Oracle's NUMBER and RAW types). These built-in types served applications well for quite a few years, since SQL database systems were used principally to manage "traditional" data: data easily represented using numbers, character strings, and datetime values.
However, as time...