Skip site navigation (1) Skip section navigation (2)

User defined types -- Social Security number...

From: "Greg Patnude" <gpatnude(at)hotmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: User defined types -- Social Security number...
Date: 2004-02-21 02:31:00
Message-ID: c16fu8$2ro4$1@news.hub.org (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-sql
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.

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

    1) checks that all numbers are in the range [0..9]
    2) inserts the dashes at position
    3) accepts either '000123456' OR '000-12-3456' as the input
    4) leading zeroes (as in the above) must be stored -- hence varchar(11)
instead of numeric
    5) always outputs in thje format '000-12-3456'

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

-- 
Greg Patnude / The Digital Demention
2916 East Upper Hayden Lake Road
Hayden Lake, ID 83835
(208) 762-0762



Responses

pgsql-hackers by date

Next:From: Scott GoodwinDate: 2004-02-21 04:34:37
Subject: Mac OS X, PostgreSQL, PL/Tcl
Previous:From: Nicolai TufarDate: 2004-02-21 02:23:17
Subject: Re: 7.4.1 release status - Turkish Locale

pgsql-sql by date

Next:From: V i s h a l Kashyap @ [Sai Hertz And Control Systems]Date: 2004-02-21 08:12:22
Subject: Re: Function
Previous:From: scott.marloweDate: 2004-02-20 21:18:03
Subject: Re: Date Foo.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group