Re: R: [postgresql-it] no cascade triggers?

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: "Manera, Villiam" <vmanera(at)manord(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, Chris Mair <chris(at)1006(dot)org>, postgresql-it <postgresql-it(at)lists(dot)psql(dot)it>
Subject: Re: R: [postgresql-it] no cascade triggers?
Date: 2007-06-27 18:31:34
Message-ID: 20070627183134.GD22179@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Doug Knight 2007-06-27 19:17:46 Capturing binary and other output destined for "make install"
Previous Message Martijn van Oosterhout 2007-06-27 18:00:36 Re: GiST consistent function, expected arguments; multi-dimensional indexes