Re: check - Mailing list pgsql-sql

From Manfred Koizar
Subject Re: check
Date
Msg-id gf3sgu486fbgrvb0tc5hpqp7dl0shqvdkh@4ax.com
Whole thread Raw
In response to check  (Matt <matthew.berardi@weilpublishing.com>)
List pgsql-sql
On Fri, 14 Jun 2002 14:47:32 -0400, Matt
<matthew.berardi@weilpublishing.com> wrote:
>how would you go about enforcing the default value:
>
>I have a nextval('seq') as my default and on an insert I don't want any 
>other value to be allowed.

Matt,
   CREATE TABLE tab (id INTEGER NOT NULL DEFAULT 0, ...

and add a before insert trigger that *unconditionally* puts
nextval('seq') into new.id.  I guess, you don't want to allow your
users to change the id of an existing row, so you might also want to
add a before update trigger that sets new.id to old.id.

ServusManfred


pgsql-sql by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: check
Next
From: Jeff Boes
Date:
Subject: Re: Limiting database size