Re: Best data type to use for sales tax percent

From: Christophe Pettus <xof(at)thebuild(dot)com>
To: "pgsql-general(at)postgresql(dot)org mailing list" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Best data type to use for sales tax percent
Date: 2009-10-09 18:46:22
Message-ID: 9F829971-4114-4285-9A05-1D8C19AA8E46@thebuild.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Oct 9, 2009, at 11:36 AM, Mike Christensen wrote:

> Can you explain what you mean by "put it in a domain" - I'd love extra
> style points, but this sounds like a feature I haven't learned about
> yet.

http://www.postgresql.org/docs/8.4/interactive/sql-createdomain.html

Domains are basically type aliases with an optional CHECK clause, so
you could do something like:

CREATE DOMAN sales_tax_rate AS DECIMAL(5,5) CHECK (VALUE >= 0);

Then, you can use the type "sales_tax_rate" in your tables, etc. just
as a normal first-class type. (The only limitation, right now, is
that you can't create an array of them.)

In response to the other email, DECIMAL is definitely the better
solution for what you are looking for.

--
-- Christophe Pettus
xof(at)thebuild(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Gould 2009-10-09 19:03:38 Re: interface for "non-SQL people"
Previous Message Mike Christensen 2009-10-09 18:36:30 Re: Best data type to use for sales tax percent