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

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: User defined types -- Social Security number...
Дата
Msg-id 200402221132.50311.josh@agliodbs.com
обсуждение исходный текст
Ответ на User defined types -- Social Security number...  ("Greg Patnude" <gpatnude@hotmail.com>)
Ответы Re: User defined types -- Social Security number...  (Bruce Momjian <pgman@candle.pha.pa.us>)
Список 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 по дате отправления:

Предыдущее
От: elein
Дата:
Сообщение: Re: searching polygons
Следующее
От: Josh Berkus
Дата:
Сообщение: Re: Compiling pl/pgsql functions