Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id D87064762D8 for ; Mon, 17 Jun 2002 13:39:08 -0400 (EDT) Received: from email01.aon.at (WARSL402PIP3.highway.telekom.at [195.3.96.97]) by postgresql.org (Postfix) with SMTP id 6105F4765C8 for ; Mon, 17 Jun 2002 12:35:16 -0400 (EDT) Received: (qmail 452246 invoked from network); 17 Jun 2002 16:35:17 -0000 Received: from m156p026.dipool.highway.telekom.at (HELO cantor) ([62.46.9.122]) (envelope-sender ) by qmail1rs.highway.telekom.at (qmail-ldap-1.03) with SMTP for ; 17 Jun 2002 16:35:17 -0000 From: Manfred Koizar To: Matt Cc: pgsql-sql@postgresql.org Subject: Re: check Date: Mon, 17 Jun 2002 18:35:05 +0200 Message-ID: References: <3D0A3A44.2090401@weilpublishing.com> In-Reply-To: <3D0A3A44.2090401@weilpublishing.com> X-Mailer: Forte Agent 1.8/32.548 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200206/219 X-Sequence-Number: 8184 On Fri, 14 Jun 2002 14:47:32 -0400, Matt 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