pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PFC <lists@boutiquenumerique.com>
To: Mike Rylander <mrylander@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Re: ENUM like data type
Date: Tue, 28 Jun 2005 18:58:32 +0200
Message-ID: <op.ss3aruu5th1vuj@localhost> (raw)
In-Reply-To: <b918cf3d050628042253044ba@mail.gmail.com>
References: <11bgc1oblfasq3d@corp.supernews.com>
	<b918cf3d050628042253044ba@mail.gmail.com>


>> 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.



view thread (9+ messages)  latest in thread

Message-ID: <op.ss3aruu5th1vuj@localhost>
Permalink:  ../op.ss3aruu5th1vuj@localhost/
Also on:    postgresql.org/message-id/op.ss3aruu5th1vuj@localhost

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: lists@boutiquenumerique.com, mrylander@gmail.com, pgsql-sql@postgresql.org
  Subject: Re: ENUM like data type
  In-Reply-To: <op.ss3aruu5th1vuj@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox