Re: Trigger question

From: Terry Lee Tucker <terry(at)chosen-ones(dot)org>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Trigger question
Date: 2008-02-22 14:17:47
Message-ID: 200802220917.47675.terry@chosen-ones.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Friday 22 February 2008 05:24, Alex du Plessis wrote:
> I would like to prevent changes being made to a table (b), except when a
> trigger fires as a result of changes (insert,update) being made to
> another table (a). Should any changes be made to table b by any other
> means than the trigger from table a, I would like to trap those changes
> (again, could I use a trigger?) and make sure that the original values
> in table b stays the same.
>
> Can anybody point me in the right direction please.
>

I suppose there are several ways to accomplish this. One is to create a small
table explicitly for this purpose containing whatever you want but making
sure that the table has the backend pid stored in it. You can have an AFTER
trigger on table a insert data into this table and you can have a BEFORE
trigger on table b check for the existence of a record with the same pid and
if found, read data out of the table and make the update. Then, delete the
table entry.

Just one way...
--
Terry Lee Tucker
Turbo's IT Manager
Turbo, division of Ozburn-Hessey Logistics
2251 Jesse Jewell Pkwy NE
Gainesville, GA 30501
Tel: (336) 372-6812 Fax: (336) 372-6812 Cell: (336) 404-6987
terry(at)turbocorp(dot)com
www.turbocorp.com

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Maciej Sieczka 2008-02-22 21:46:18 how to auto GRANT rights on a new table?
Previous Message Alex du Plessis 2008-02-22 10:24:32 Trigger question