X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 239D8D1B4F4 for ; Tue, 4 Nov 2003 22:33:50 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 98163-07 for ; Tue, 4 Nov 2003 18:33:21 -0400 (AST) Received: from frankenbride.clueinc.net (xd84b4366.ip.e-nt.net [216.75.67.102]) by svr1.postgresql.org (Postfix) with ESMTP id 6BB4BD1B502 for ; Tue, 4 Nov 2003 18:33:18 -0400 (AST) Received: by frankenbride.clueinc.net (Postfix, from userid 16220) id 29ECFBA34; Tue, 4 Nov 2003 17:33:19 -0500 (EST) Date: Tue, 4 Nov 2003 17:33:19 -0500 From: Jamie Lawrence To: pgsql-sql@postgresql.org Subject: Problems with NEW.* in triggers Message-ID: <20031104223319.GA2879@clueinc.net> Mail-Followup-To: pgsql-sql@postgresql.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.28i Organization: clue inc X-URL: http://www.clueinc.net/ X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200311/20 X-Sequence-Number: 15835 Hi folks - I'm having a problem with what looks like it should be trivial. For the function create or replace function timestamp_fn() returns opaque as ' begin NEW.moddate := coalesce(NEW.moddate, now()); return NEW; end ' language 'plpgsql'; on an after insert or update trigger, never sets moddate to now(). I had thought that if moddate isn't included in an insert or update, that it would be null in the NEW context, so that this would fall through to the now() call. (I also tried this as below: create or replace function timestamp_fn() returns opaque as ' begin if NEW.moddate is not null then return NEW; else NEW.moddate := now(); return NEW; end if; end ' language 'plpgsql'; With the same results.) Any thoughts on what I'm doing wrong?? -j -- Jamie Lawrence jal@jal.org Never eat anything bigger than your head.