Trigger on view - Mailing list pgsql-sql

From Kyle
Subject Trigger on view
Date
Msg-id 3F68BA18.2040000@actarg.com
Whole thread Raw
List pgsql-sql
I'm trying to set up a trigger that restricts when and how updates are 
done to the records in a relation.  However, when the administrator 
accesses the relation, I want the restriction to be relaxed.

My approach was to have a view that is accessed by the normal users and 
have the admin access the table directly.  However, it doesn't appear 
that I can actually apply a trigger to a view.

Some of this I can do with rules on the view, but certain restrictions 
are applicable only on a row-by-row basis, so I think I need to do it in 
a BEFORE trigger.

Is there a way I can either:

1. Apply a trigger to a view.  The trigger would actually get registered 
with the underlying table, but would only be invoked if the user had 
entered via the view.

2. Detect inside the trigger function whether the user had accessed the 
table directly or through the view so I could invoke conditional code 
accordingly.

I want to avoid hardcoding user ID's in the trigger, so I'm trying to 
take this approach so it can all be handled simply by granting 
privileges on different views to enable/disable the varying levels of 
restriction.

Any ideas?

Kyle Bateman




pgsql-sql by date:

Previous
From: miko@idocs.com (Miko O'Sullivan)
Date:
Subject: Re: [BUGS] session variable
Next
From: wireless200@yahoo.com (wireless)
Date:
Subject: how to get decimal to date form