Re: User defined types -- Social Security number...

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: "Greg Patnude" <gpatnude(at)hotmail(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: User defined types -- Social Security number...
Date: 2004-02-22 19:32:50
Message-ID: 200402221132.50311.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message HORNYAK Laszlo 2004-02-22 20:33:21 Re: Pl/Java - next step?
Previous Message Thomas Hallgren 2004-02-22 19:08:00 Re: Pl/Java - next step?

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2004-02-22 19:34:47 Re: Compiling pl/pgsql functions
Previous Message joseph speigle 2004-02-22 18:54:59 Re: [SQL] crosstabs