RE: Use a rule or a transaction

From: Jesus Aneiros <aneiros(at)jagua(dot)cfg(dot)sld(dot)cu>
To: "Madel, Kurt" <KMadel(at)USInspect(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: RE: Use a rule or a transaction
Date: 2000-08-15 19:55:39
Message-ID: Pine.LNX.4.10.10008151551040.23637-100000@jagua.cfg.sld.cu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Create a trigger on module before update or insert. The philosophy of
postgres is to create a trigger based on a function previously created.
Take a look at the docs, the part on procedural languages. The book
from Momjian has one or two examples on triggers creation.

--
Jesus Aneiros Sosa
mailto:aneiros(at)jagua(dot)cfg(dot)sld(dot)cu
http://jagua.cfg.sld.cu/~aneiros

On Tue, 15 Aug 2000, Madel, Kurt wrote:

> 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(at)hansonpublications(dot)com]
> Sent: Tuesday, August 15, 2000 2:43 PM
> To: Madel, Kurt
> Cc: pgsql-sql(at)postgresql(dot)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 <o>
> <|> antoiner(at)hansonpublications(dot)com <| don't mix. Never drink |
> >\ antoiner(at)edmarketing(dot)com >\ and derive. /<
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Madel, Kurt 2000-08-15 20:02:19 RE: Use a rule or a transaction
Previous Message Antoine Reid 2000-08-15 19:49:13 Re: Use a rule or a transaction