Re: R: [postgresql-it] no cascade triggers? - Mailing list pgsql-hackers

From Martijn van Oosterhout
Subject Re: R: [postgresql-it] no cascade triggers?
Date
Msg-id 20070627183134.GD22179@svana.org
Whole thread Raw
In response to R: [postgresql-it] no cascade triggers?  ("Manera, Villiam" <vmanera@manord.com>)
Responses R: R: [postgresql-it] no cascade triggers?
List pgsql-hackers
On Wed, Jun 27, 2007 at 11:37:01AM +0200, Manera, Villiam wrote:
> To better explain my problem I attach one of my functions that is easy
> to understand.
>
> For each of my products I must have one main supplier and I may have
> also some secondary suppliers.
>
> Therefore for each of my articles
> I have as many records in table ANAMAT.ART_FOR as the number of my
> suppliers for that article.
>
> The main supplier is identified by code 1 in the column ARF_PROGR_FORN.
> Secondary suppliers are numbered as 2,3 and so on
>
> If, for example, I want to promote one of the secondary suppliers (let's
> say number 3)
> to be the main one, I should issue the following update:

To be honest, it seems to me your problem is that you're trying to use
triggers for something they're not designed for. What seems to be
infinitly easier is to write a stored proc that you use like so:

SELECT promote_supplier( article, supplier );

No trigger necessary...

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

pgsql-hackers by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: GiST consistent function, expected arguments; multi-dimensional indexes
Next
From: Stephen Frost
Date:
Subject: Re: Bugtraq: Having Fun With PostgreSQL