Re: ENUM like data type

From: PFC <lists(at)boutiquenumerique(dot)com>
To: "Mike Rylander" <mrylander(at)gmail(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: ENUM like data type
Date: 2005-06-28 16:58:32
Message-ID: op.ss3aruu5th1vuj@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql


>> Here is where I get uncertain as to if this is possible. My idea is to
>> create a pseudo type that triggers the creation of it's lookup tables
>> the same way the SERIAL type triggers creation of a sequence and returns
>> an int with the right default value.

Personnally I use one table which has columns (domain, name) and which
stores all enum values for all different enums.
I have then CHECK( is_in_domain( column, 'domain_name' )) which is a
simple function which checks existence of the value in this domain (SELECT
1 FROM domains WHERE domain=$2 AND name=$1 LIMIT 1) for instance.
You can also use integers.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2005-06-28 16:58:52 Re: Role syntax (or, SQL99 versus sanity)
Previous Message Dave Cramer 2005-06-28 16:54:49 Re: Implementing SQL/PSM for PG 8.2 - debugger

Browse pgsql-sql by date

  From Date Subject
Next Message PFC 2005-06-28 17:01:07 Re: Unique primary index?
Previous Message Tom Lane 2005-06-28 14:31:46 Re: ERROR: "TZ"/"tz" not supported