Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id AF0BB9FA06C for ; Tue, 4 Sep 2007 12:14:10 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 00371-06 for ; Tue, 4 Sep 2007 12:13:49 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from ns2.instrumentalyst.com (blk-222-55-203.eastlink.ca [24.222.55.203]) by postgresql.org (Postfix) with ESMTP id 835A29FA05A for ; Tue, 4 Sep 2007 12:14:07 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by ns2.instrumentalyst.com (Postfix) with ESMTP id 7D2BB1635 for ; Tue, 4 Sep 2007 12:10:23 -0300 (ADT) X-Virus-Scanned: amavisd-new at instrumentalyst.com Received: from ns2.instrumentalyst.com ([127.0.0.1]) by localhost (ns2.instrumentalyst.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fFi692-2mAhz for ; Tue, 4 Sep 2007 12:10:16 -0300 (ADT) Received: from nakul.home (pool-71-180-50-229.tampfl.fios.verizon.net [71.180.50.229]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ns2.instrumentalyst.com (Postfix) with ESMTP id DB3CD14B5 for ; Tue, 4 Sep 2007 12:10:15 -0300 (ADT) Message-ID: <46DD7634.4090408@productivitymedia.com> Date: Tue, 04 Sep 2007 11:13:56 -0400 From: PostgreSQL Admin User-Agent: Thunderbird 2.0.0.6 (Macintosh/20070728) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Trigger to change different row in same table References: <46DCE263.6040207@obviously.com> <46DD0E81.2000901@obviously.com> <46DD6E44.4000505@obviously.com> In-Reply-To: <46DD6E44.4000505@obviously.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.926 tagged_above=0 required=5 tests=AWL=-0.085, BAYES_20=-0.74, FH_HOST_ALMOST_IP=1.751 X-Spam-Level: X-Archive-Number: 200709/37 X-Sequence-Number: 29250 I want to write a trigger that updates a different row on the same table. It's pretty basic: before the any row in his table updated I want to set a only row that has the value true to false. I keep getting this error: SQL statement "update theirry.articles set master_featured = false where master_featured = true" PL/pgSQL function "master_featured_maintenance" line 4 at SQL statement My basic trigger: CREATE OR REPLACE FUNCTION theirry.master_featured_maintenance() RETURNS TRIGGER AS $master_featured_maintenance$ DECLARE master_feature boolean; BEGIN update theirry.articles set master_featured = false where master_featured = true; END; $master_featured_maintenance$ LANGUAGE plpgsql; CREATE TRIGGER master_featured_maintenance BEFORE INSERT OR UPDATE ON theirry.articles FOR EACH ROW EXECUTE PROCEDURE theirry.master_featured_maintenance(); Thanks in advance, J