EVAL and SET equivalents in PostgreSQL

From: Lynn David Newton <lynn(dot)newton(at)cox(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: EVAL and SET equivalents in PostgreSQL
Date: 2002-07-02 20:06:24
Message-ID: cn1r8ildhbd.fsf@bela.interhack.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


This is no doubt asked frequently, but I have exactly two days
experience with PostgreSQL, and am hot on a project for which I need a
more-or-less immediate answer.

Most of my previous DB experience has been with MySQL, which supported
ENUM('value1','value2'...) data types, to allow a column to be
assigned the value of exactly one item from the list, and also the
SET('value1','value2',...) type to allow zero or more members of the
set of values.

I need this functionality or something equivalent in a DB I'm setting
up on a project, and a half day of rumbling around in man pages and
printed documentation has yielded no obvious answer. I did learn about
creating arrays, but that's not exactly what I want.

If I try to INSERT an illegel value for a SET or ENUM field, MySQL
will return an error message, which is what you want it to do.

Without that, you have to add a layer of programming to intercept the
values that are coming in and verify that it's good stuff -- lots of
trouble that I'd like to avoid if possible.

I'm asking this group because I know that surely I am not the first
migrant from MySQL to come up against this problem, and suspect the
answer is common knowledge that I have not yet groked.

Many thanks for any insights shared.

--
Lynn David Newton
Phoenix, AZ

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-07-02 22:27:49 Re: One source of constant annoyance identified
Previous Message Lamar Owen 2002-07-02 19:50:05 Re: (A) native Windows port