X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id DA2689FB2B4 for ; Sun, 20 Aug 2006 07:35:38 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 68966-09 for ; Sun, 20 Aug 2006 10:35:29 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mtaout01-winn.ispmail.ntl.com (mtaout01-winn.ispmail.ntl.com [81.103.221.47]) by postgresql.org (Postfix) with ESMTP id 2C2939FB258 for ; Sun, 20 Aug 2006 07:34:55 -0300 (ADT) Received: from aamtaout01-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout01-winn.ispmail.ntl.com with ESMTP id <20060820103450.MWGE15018.mtaout01-winn.ispmail.ntl.com@aamtaout01-winn.ispmail.ntl.com>; Sun, 20 Aug 2006 11:34:50 +0100 Received: from Wilbur ([86.14.228.87]) by aamtaout01-winn.ispmail.ntl.com with SMTP id <20060820103450.LNSU644.aamtaout01-winn.ispmail.ntl.com@Wilbur>; Sun, 20 Aug 2006 11:34:50 +0100 Message-ID: <0cb101c6c444$44867300$0600a8c0@Wilbur> From: "Julian Scarfe" To: "Markus Schaber" Cc: References: <029c01c6c228$8e8e5210$0600a8c0@Wilbur> <44E6C30D.1070608@logix-tt.com> Subject: Re: NULL becomes default Date: Sun, 20 Aug 2006 11:34:48 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="ISO-8859-15"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2869 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.135 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200608/147 X-Sequence-Number: 26105 >> Thus I would like NULLs in such INSERTs to be treated as DEFAULT rather >> than violating the constraint. Is there an easy way to do that at the >> database level? From: "Markus Schaber" > Did you try a "before insert" trigger that checks new_id for null > values, and replaces it with nextval()? So thinking about this a little more, it requires me to be able to change a column value to DEFAULT (unless I implement the default from scratch in the trigger, but that feels messy). I don't have much experience of triggers: can I do that? Thanks Julian