Received: from wumpus.lan.edmarketing.com (djinn.edmarketing.com [209.167.170.135]) by hub.org (8.10.1/8.10.1) with ESMTP id e7FIl6n13656 for ; Tue, 15 Aug 2000 14:47:06 -0400 (EDT) Received: (from fluke@localhost) by wumpus.lan.edmarketing.com (8.11.0/8.11.0/Debian 8.11.0-1) id e7FIhKr21414; Tue, 15 Aug 2000 14:43:20 -0400 Date: Tue, 15 Aug 2000 14:43:14 -0400 From: Antoine Reid To: "Madel, Kurt" Cc: pgsql-sql@postgresql.org Subject: Re: Use a rule or a transaction Message-ID: <20000815144314.A21306@wumpus.lan.edmarketing.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from KMadel@USInspect.com on Tue, Aug 15, 2000 at 01:57:17PM -0400 X-Archive-Number: 200008/134 On Tue, Aug 15, 2000 at 01:57:17PM -0400, Madel, Kurt wrote: > Hello, > > I am creating a web based (using php) class registration database with three > tables directly effected by the registration process: [snip] > My question is, would it be better (faster) to use rules or to use a > transaction. How about using triggers? I have used pl/pgsql triggers in the past to do similar things. I was not checking a maximum but definitely was keeping a reference count. What you want is a trigger that increments on insert, decrement on delete, and on update, IF the id changed, decrement the old one, increment the new one.. I suspect you could also have another trigger, on update on class, that would abort the transaction if class.size ever becomes bigger than maxsize.. I can't really comment on performance though..... > Is there a faster way to do this with rules or a better way to do it > otherwise. > > TIF, > Kurt Hope it helps Antoine -- o Antoine Reid o> Alcohol and calculus <|> antoiner@hansonpublications.com <| don't mix. Never drink | >\ antoiner@edmarketing.com >\ and derive. /<