Re: Trigger question - Mailing list pgsql-novice

From Terry Lee Tucker
Subject Re: Trigger question
Date
Msg-id 200802220917.47675.terry@chosen-ones.org
Whole thread Raw
In response to Trigger question  (Alex du Plessis <alexdup01@telkomsa.net>)
Responses Foreign key violation
List 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@turbocorp.com
www.turbocorp.com

pgsql-novice by date:

Previous
From: Alex du Plessis
Date:
Subject: Trigger question
Next
From: Maciej Sieczka
Date:
Subject: how to auto GRANT rights on a new table?