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