Re: Checking number of entries

From: Alfred Perlstein <bright(at)wintelcom(dot)net>
To: "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-28 23:57:30
Message-ID: 20000928165730.Z7553@fw.wintelcom.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

* 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
>
> What is the proper way of doing this? I want to be able to force a minimum and
> maximum number of entries.

Use a trigger on INSERT that does that.

--
-Alfred Perlstein - [bright(at)wintelcom(dot)net|alfred(at)freebsd(dot)org]
"I have the heart of a child; I keep it in a jar on my desk."

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alejandro Federico Pérez López 2000-09-29 01:01:22 A newbie question
Previous Message Wade D. Oberpriller 2000-09-28 22:28:39 Checking number of entries