X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 02EBB3A50C6 for ; Mon, 22 Nov 2004 01:56:29 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 28060-05 for ; Mon, 22 Nov 2004 01:56:17 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 05BB43A50C4 for ; Mon, 22 Nov 2004 01:56:19 +0000 (GMT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.1/8.13.1) with ESMTP id iAM1uDIs008819 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 21 Nov 2004 18:56:15 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.1/8.13.1) with ESMTP id iAM1uDej042701; Sun, 21 Nov 2004 18:56:13 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.1/8.13.1/Submit) id iAM1uCGo042700; Sun, 21 Nov 2004 18:56:12 -0700 (MST) (envelope-from mfuhr) Date: Sun, 21 Nov 2004 18:56:12 -0700 From: Michael Fuhr To: "Di Croce, Tony" Cc: "'pgsql-admin@postgresql.org'" Subject: Re: Stamping rows... Message-ID: <20041122015612.GA42649@winnie.fuhr.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/162 X-Sequence-Number: 15546 On Thu, Nov 18, 2004 at 04:23:50PM -0800, Di Croce, Tony wrote: > I am trying to find a way to stamp all of the rows affected by an update (or > insert) with a unique value. [snip] > At first I tried to do this as a trigger function. The problem with this > solution is that if I dont have the function called for each row, I cannot > modify those rows. if I DO have the function called for each row, how do > they get the "change_number" they cannot simply call nextval() as it will be > different for each row (they also couldn't call curval() because then who is > ever calling nextval()?) Have you tried calling nextval() in a FOR EACH STATEMENT trigger and currval() in a FOR EACH ROW trigger? This works for me in simple tests. I don't know if statement triggers are guaranteed to fire before row triggers, but they do appear to work that way. -- Michael Fuhr http://www.fuhr.org/~mfuhr/