Re: Are globally defined constants possible at all ? - Mailing list pgsql-general

From Nigel J. Andrews
Subject Re: Are globally defined constants possible at all ?
Date
Msg-id Pine.LNX.4.21.0206091639010.4131-100000@ponder.fairway2k.co.uk
Whole thread Raw
In response to Re: Are globally defined constants possible at all ?  (Andrew Sullivan <andrew@libertyrms.info>)
Responses Re: Are globally defined constants possible at all ?  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Are globally defined constants possible at all ?  (Darren Ferguson <darren@crystalballinc.com>)
List pgsql-general
On Fri, 7 Jun 2002, Andrew Sullivan wrote:

> On Fri, Jun 07, 2002 at 05:29:27PM -0400, Gregory Seidman wrote:
> >
> > Er, could you expand on that? Are you suggesting something like this:
> >
> > CREATE TABLE Foo (
> >     KindID int,
> >     ...
> >     CONSTRAINT fooenum
> >     CHECK KindID IN ('SOFTWARE', 'HARDWARE')
> > );
>
> Yes.  Except I think you need another set of parentheses
>
>     check("KindID" IN ('SOFTWARE','HARDWARE'))

Can this be done? What are the integers derived from the strings and is there
any chance of them not being unique?

The following message shows a what I think is a more consistent way of writing
it but I still can't see how use of CHECK makes the mapping from a textual type
to integer.


Darren Ferguson wrote on Sun Jun  9 at 16:38:53 2002
>
>Check can be used in the following way
>
>status VARCHAR(32) DEFAULT 'new' NOT NULL
>    CHECK(status IN ('new','read','deleted')),
>
>On Fri, 7 Jun 2002, Nigel J. Andrews wrote:
>
>
>> On Fri, 7 Jun 2002, Andrew Sullivan wrote:
>> >
>> > On Fri, Jun 07, 2002 at 02:36:35PM -0400, Gregory Seidman wrote:
>> >
>> > > I am in the exact same position. I have a number of things which are
>> > > essentially enumerations. Since PostgreSQL does not support an
enumeration
>> > > type (MySQL does, but then it doesn't have a proper boolean type), I
have a
>> >
>> > Why don't you use a CHECK contraint?  That's the standard way to do
>> > it.
>>
>> I wonder if you could explain how to use CHECK for this please? I'm having a
>> little trouble thinking in that manner but then I've only seen and used the
>> table associating name and value method before and so am a little biased.


--
Nigel J. Andrews
Director

---
Logictree Systems Limited
Computer Consultants




pgsql-general by date:

Previous
From: Alan Wayne
Date:
Subject: Re: Help with data transfer please
Next
From: Tom Lane
Date:
Subject: Re: Are globally defined constants possible at all ?