Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: Trigger question



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



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group