Re: User defined types -- Social Security number... - Mailing list pgsql-sql

From Josh Berkus
Subject Re: User defined types -- Social Security number...
Date
Msg-id 200402221132.50311.josh@agliodbs.com
Whole thread Raw
In response to User defined types -- Social Security number...  ("Greg Patnude" <gpatnude@hotmail.com>)
Responses Re: User defined types -- Social Security number...  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-sql
Greg,

> Anyone have a good pre-built user-defined type definition for creating /
> maintaining / manipulating a SSN ... where valid chars are in the range
> 000-00-0000 through 999-99-9999.

Actually, the range is more narrowly defined than that.  I'm not sure of the 
exact rules, but you will never see a leading 0 or a -00- in an SSN.

> I imagine that the storage column is probably varchar(11) -- I am looking
> for a type definition that

Use DOMAINs, not a custom type.  It's less work.

> Either that or the question is: How can I coerce postgreSQL into using an
> input / output "mask"...

After you've created your DOMAIN, based on the TEXT type, you can overload the 
input and output functions to format correctly.   Beware, though: input & 
output functions pretty much have to be written in C.

-- 
Josh Berkus
Aglio Database Solutions
San Francisco


pgsql-sql by date:

Previous
From: elein
Date:
Subject: Re: searching polygons
Next
From: Josh Berkus
Date:
Subject: Re: Compiling pl/pgsql functions