Trigger on view

From: Kyle <kyle(at)actarg(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Trigger on view
Date: 2003-09-17 19:46:32
Message-ID: 3F68BA18.2040000@actarg.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-sql by date

  From Date Subject
Next Message Tomasz Myrta 2003-09-17 20:24:34 Re: how to get decimal to date form
Previous Message tiagoalves 2003-09-17 17:20:35 Triggers Help...