X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 9AD5FD1B982 for ; Sun, 22 Feb 2004 19:35:02 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 43627-07 for ; Sun, 22 Feb 2004 15:35:00 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id B83F0D1B90E for ; Sun, 22 Feb 2004 15:34:58 -0400 (AST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4475126; Sun, 22 Feb 2004 11:36:08 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: "Greg Patnude" , pgsql-sql@postgresql.org Subject: Re: User defined types -- Social Security number... Date: Sun, 22 Feb 2004 11:32:50 -0800 User-Agent: KMail/1.4.3 References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200402221132.50311.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/333 X-Sequence-Number: 17023 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