Re: Checking number of entries - Mailing list pgsql-general

From Philip Warner
Subject Re: Checking number of entries
Date
Msg-id 3.0.5.32.20000929111936.009fe540@mail.rhyme.com.au
Whole thread Raw
In response to Re: Checking number of entries  (Alfred Perlstein <bright@wintelcom.net>)
Responses Re: Checking number of entries
Re: Checking number of entries
List pgsql-general
At 16:57 28/09/00 -0700, Alfred Perlstein wrote:
>* Wade D. Oberpriller <oberpwd@anubis.network.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   |/

pgsql-general by date:

Previous
From: Alfred Perlstein
Date:
Subject: Re: Checking number of entries
Next
From: Alejandro Federico Pérez López
Date:
Subject: A newbie question