X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.192]) by svr1.postgresql.org (Postfix) with ESMTP id 4EBEFCD0A3 for ; Sun, 20 Jul 2003 06:14:27 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr4.postgresql.org [64.117.224.192]) (amavisd-new, port 10024) with ESMTP id 05413-05 for ; Sun, 20 Jul 2003 06:15:02 +0000 (GMT) Received: from megazone.bigpanda.com (unknown [66.180.233.26]) by svr1.postgresql.org (Postfix) with ESMTP id 54B65CD08C for ; Sun, 20 Jul 2003 03:14:25 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 8A82FD635; Sat, 19 Jul 2003 23:15:02 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 57D285C14; Sat, 19 Jul 2003 23:15:01 -0700 (PDT) Date: Sat, 19 Jul 2003 23:15:01 -0700 (PDT) From: Stephan Szabo To: Lauren Matheson Cc: Subject: Re: changing an update via rules In-Reply-To: <1058307247.26006.8.camel@nicoll> Message-ID: <20030719231214.Y55138-100000@megazone.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/298 X-Sequence-Number: 14412 On 15 Jul 2003, Lauren Matheson wrote: > Hello, > > I am having difficulty setting an on update rule which seems to be > caught in a recursive loop. > > Context is a table with three columns assigning users to groups with the > third column being boolean to flag the primary group. I would like to > set an update rule to enforce one primary group. Any suggestions on how > to do this, or exactly how the code is getting trapped? My code is Rules are like macro rewrites and the WHERE clauses will not help to break the recursive loop. I think you may need to either use a trigger or something like a view so that the actual action happens on a different table.