Re: check

From: Manfred Koizar <mkoi-pg(at)aon(dot)at>
To: Matt <matthew(dot)berardi(at)weilpublishing(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: check
Date: 2002-06-17 16:35:05
Message-ID: gf3sgu486fbgrvb0tc5hpqp7dl0shqvdkh@4ax.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Fri, 14 Jun 2002 14:47:32 -0400, Matt
<matthew(dot)berardi(at)weilpublishing(dot)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.

Servus
Manfred

In response to

  • check at 2002-06-14 18:47:32 from Matt

Browse pgsql-sql by date

  From Date Subject
Next Message Jeff Boes 2002-06-17 16:52:47 Re: Limiting database size
Previous Message Stephan Szabo 2002-06-17 14:55:23 Re: check