Re: US Telephone Number Type - Mailing list pgsql-general

From Tom Lane
Subject Re: US Telephone Number Type
Date
Msg-id 24142.1152560303@sss.pgh.pa.us
Whole thread Raw
In response to US Telephone Number Type  ("Karen Hill" <karen_hill22@yahoo.com>)
Responses Re: US Telephone Number Type  ("Karen Hill" <karen_hill22@yahoo.com>)
List pgsql-general
"Karen Hill" <karen_hill22@yahoo.com> writes:
> How would one go about creating a US telephone type in the format of
> "(555)-555-5555" ?

Are you sure that's what you want?  Even within the US there's the issue
of extension numbers; I'm not sure how useful it is to have a datatype
that refuses anything but the basic 10-digit format.

It doesn't seem particularly hard to make a type that stores just the
digits (applying whatever amount of error-checking seems appropriate
on the non-digit stuff it's throwing away) and on output regurgitates
a standardized format.  Minimum support would just be an input function
and an output function, and it doesn't seem like you need too many other
functions besides them ... do you need indexing support?

> Should the telephone type be able to do something such as:
> SELECT * from tableFOO where telephone.areacode = 555;

It'd be syntactically easier as a function:

    areacode(telephone) = 555

            regards, tom lane

pgsql-general by date:

Previous
From: Vivek Khera
Date:
Subject: Re: US Telephone Number Type
Next
From: Karsten Hilbert
Date:
Subject: timestamp with definable accuracy, was: Re: empty text fields