Martijn van Oosterhout <kleptog@xxxxxxxxx> writes: > On Tue, Jan 25, 2005 at 02:31:40PM -0500, Tom Lane wrote: >> AFAICS this could easily be implemented as a user-defined type, along >> the lines of >> CREATE TYPE measurement AS (value double, units text); >> and if you want to constrain a particular column to contain only one >> value of units, use CHECK. > I've tried this but I can't work out how to make it work. For composite > types you can't specify input and output functions. No, but as of 8.0 you don't really need them, assuming that you don't mind some parentheses around your output. regression=# CREATE TYPE measurement AS (value float, units text); CREATE TYPE regression=# select cast( (5,'a') as measurement); row ------- (5,a) (1 row) Or you can implement it as a scalar type if you really want to define your own I/O functions. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to majordomo@xxxxxxxxxxxxxx)