pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Manfred Koizar <mkoi-pg@aon.at>
To: Matt <matthew.berardi@weilpublishing.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: check
Date: Mon, 17 Jun 2002 18:35:05 +0200
Message-ID: <gf3sgu486fbgrvb0tc5hpqp7dl0shqvdkh@4ax.com> (raw)
In-Reply-To: <3D0A3A44.2090401@weilpublishing.com>
References: <3D0A3A44.2090401@weilpublishing.com>

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.

Servus
 Manfred



view thread (4+ messages)

Message-ID: <gf3sgu486fbgrvb0tc5hpqp7dl0shqvdkh@4ax.com>
Permalink:  ../gf3sgu486fbgrvb0tc5hpqp7dl0shqvdkh@4ax.com/
Also on:    postgresql.org/message-id/gf3sgu486fbgrvb0tc5hpqp7dl0shqvdkh@4ax.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mkoi-pg@aon.at, matthew.berardi@weilpublishing.com
  Subject: Re: check
  In-Reply-To: <gf3sgu486fbgrvb0tc5hpqp7dl0shqvdkh@4ax.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox