Received: from exchhq01.usinspect.com (exchhq01.usinpect.com [208.233.45.2] (may be forged)) by hub.org (8.10.1/8.10.1) with ESMTP id e7FIr6n18343 for ; Tue, 15 Aug 2000 14:53:06 -0400 (EDT) Received: by exchhq01.usinspect.com with Internet Mail Service (5.5.2650.21) id ; Tue, 15 Aug 2000 14:52:26 -0400 Message-ID: From: "Madel, Kurt" To: "'Antoine Reid'" , "Madel, Kurt" Cc: pgsql-sql@postgresql.org Subject: RE: Use a rule or a transaction Date: Tue, 15 Aug 2000 14:52:24 -0400 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: text/plain; charset="iso-8859-1" X-Archive-Number: 200008/119 Hello Antoine, I thought that triggers only worked for one table at a time. In this case, I want the class.size incremented and checked for maxsize when I perform an update or insert on the module table. I was under the impression that a trigger would only work if I was performing an insert or update on the same table that I wanted the trigger to act on. Please let me know if I am way off in regards to triggers. thanks, Kurt -----Original Message----- From: Antoine Reid [mailto:antoiner@hansonpublications.com] Sent: Tuesday, August 15, 2000 2:43 PM To: Madel, Kurt Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] Use a rule or a transaction 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. /<