Re: Trigger/Rules Order of operations

From: "Emanuel Calvo Franco" <postgres(dot)arg(at)gmail(dot)com>
To: "Ketema Harris" <ketema(at)ketema(dot)net>, "General PostgreSQL List" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Trigger/Rules Order of operations
Date: 2008-12-16 18:24:33
Message-ID: f205bb120812161024x7be3e24ev4ad04a02b576cf55@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2008/12/15 Ketema Harris <ketema(at)ketema(dot)net>:
> I am interested in finding out the pros, cons, pitfalls of using the
> following design:
>
> Manual insert into Table A.
> Table A has a BEFORE INSERT trigger that causes an insert to table B.
> Table B has an AFTER INSERT trigger that causes an insert back to table A
> (With different criteria not an endless loop)
>
> Table A will have its Before Trig fire again and this time the criteria
> causes it to finish with a return new.
>
how do you will control that for each insertion on A don't
insert on B when this tuple is just inserted? WHy i do this question?
Becuase you can't put 2 before insert triggers at the same time (you
can but is not cleany)
I mean, if you want to do a 'control' of the inserted data i think is
better a good
trigger that filter data to insert, and if you want a log table make a
rule or in the same
function of the trigger put the logging

> Will the second insert into table A commit before the first insert into
> table A? What order does the insert into table B finish up?
>
the 2 triggers will execute, i think, at the same time. Just think:
waht are the
beneffits of this implementation? what do you want to resolve with it?

>
> Ketema J. Harris
> www.ketema.net
> ketema(at)ketema(dot)net
> ketemaj on iChat
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

--
Emanuel Calvo Franco
Syscope Postgresql Consultant
ArPUG / AOSUG Member

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Madison Kelly 2008-12-16 19:16:14 TIMESTAMP with a timezone offset
Previous Message Raymond O'Donnell 2008-12-16 17:51:55 Re: Trigger/Rules Order of operations