Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by hub.hub.org (8.10.1/8.10.1) with ESMTP id e9FIVfq40974 for ; Sun, 15 Oct 2000 14:31:41 -0400 (EDT) Received: from [63.195.55.98] (HELO agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 3.3) with ESMTP id 1100086 for pgsql-sql@postgresql.org; Sun, 15 Oct 2000 11:31:36 -0700 Message-ID: <39E9F80C.D9BE2054@agliodbs.com> Date: Sun, 15 Oct 2000 11:31:40 -0700 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions X-Mailer: Mozilla 4.73 [en] (Win98; I) X-Accept-Language: en MIME-Version: 1.0 To: sqllist Subject: Re: Variable-length Types References: <871yxi432t.fsf@matt.w80.math-hat.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200010/131 X-Sequence-Number: 1793 Folks, I'm a bit confused on custom type declarations, actually. I'd like to create a custom type for American phone numbers, such that: It takes a string and returns something that looks like Varchar(22); If someone types in 10 digits, it returns output like (###) ###-#### If a user enters 7 digits, it picks a default area code and returns (415) ###-####, and if they type more than 10 digits or enter any digits after an "x", they get (###) ###-#### x### My questions are as follows: 1. Can I reference a custom function (phoneformat) in a type definition? 2. If 1. is "no", is there a way to do the above without programming the type in C? 3. What sort of trouble am I going to get into trying to pull data from a custom type into an external interface (i.e. PHP4)? Thanks for your thoughts! -Josh Berkus -- ______AGLIO DATABASE SOLUTIONS___________________________ Josh Berkus Complete information technology josh@agliodbs.com and data management solutions (415) 436-9166 for law firms, small businesses fax 436-0137 and non-profit organizations. pager 338-4078 San Francisco