Re: Checking number of entries

From: Philip Warner <pjw(at)rhyme(dot)com(dot)au>
To: Alfred Perlstein <bright(at)wintelcom(dot)net>, "Wade D(dot) Oberpriller" <oberpwd(at)anubis(dot)network(dot)com>
Cc: general-help postgresql <pgsql-general(at)postgresql(dot)org>
Subject: Re: Checking number of entries
Date: 2000-09-29 01:19:36
Message-ID: 3.0.5.32.20000929111936.009fe540@mail.rhyme.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

At 16:57 28/09/00 -0700, Alfred Perlstein wrote:
>* Wade D. Oberpriller <oberpwd(at)anubis(dot)network(dot)com> [000928 15:34] wrote:
>> Hello,
>>
>> Is it possible to restrict the number of entries in a table? I have
attempted
>> to write a check like so:
>>
>> CREATE TABLE mytable (
>> id integer NOT NULL,
>> CHECK (COUNT(id) <= 10)
>> );
>>
>> This is not allowed, I get an error saying:
>>
>> ERROR: ExecEvalAggref: no aggregates in this expression context

I just tried:

CREATE TABLE mytable (
id integer NOT NULL
);

Alter TABLE mytable Add
CHECK ( (Select COUNT(distinct id) From mytable) <= 10)
);

Under 7.1 (and with the constraint in the table definition in 7.0.2) and it
lets me define the table & constraint, but when I insert into the table, I
get:

ERROR: ExecEvalExpr: unknown expression type 108

Seems to me it should either disallow the creation, or work properly.

----------------------------------------------------------------
Philip Warner | __---_____
Albatross Consulting Pty. Ltd. |----/ - \
(A.B.N. 75 008 659 498) | /(@) ______---_
Tel: (+61) 0500 83 82 81 | _________ \
Fax: (+61) 0500 83 82 82 | ___________ |
Http://www.rhyme.com.au | / \|
| --________--
PGP key available upon request, | /
and from pgp5.ai.mit.edu:11371 |/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alain Black 2000-09-29 02:05:43 RE: A newbie question
Previous Message Tim Kientzle 2000-09-29 01:06:48 Re: Re: JDBC Performance