Re: Trouble with NEW

From: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
To: David Johnston <polobo(at)yahoo(dot)com>
Cc: 'Bob Pawley' <rjpawley(at)shaw(dot)ca>, 'Alan Hodgson' <ahodgson(at)simkin(dot)ca>, pgsql-general(at)postgresql(dot)org
Subject: Re: Trouble with NEW
Date: 2012-07-19 19:13:00
Message-ID: 50085C3C.9090309@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 07/19/2012 11:26 AM, David Johnston wrote:
>>
>> 4) If you want to pull information from another table, you either need to set
>> up a FOREIGN KEY relationship that you can leverage or you need to do a
>> query in the trigger function that pulls in the necessary information.
>>
>
> I do not get where the "OR" comes from. There is nothing magical about FOREIGN KEY that causes NEW magically contain additional values. Foreign Key or not you still have to "...do a query in the trigger function...".

I think there is:)
If you have a FK between the table you have the trigger on a table you
want to update you already have the NEW or OLD values in the trigger
table with which to find the appropriate record in the other table. This
covers the OP case. Without a FK you have to create your own relationship.

>
> David J.
>
>

--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2012-07-19 19:13:08 Re: Default value of serial fields changes after restore
Previous Message David Johnston 2012-07-19 18:26:39 Re: Trouble with NEW