Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Future of Triggers
In article <1mfK5.9116$SF5.177933_at_ozemail.com.au>,
"ozi" <spuzic_at_camtech.net.au> wrote:
> Hi Everyone,
>
> Does anyone know if ORACLE are planning to introduce triggers for
views. For
> example you would be able to set a trigger on the following SQL
statement;
>
> SELECT * FROM EMP_TABLE
> WHERE EMP_SAL > 20000
>
> and whenever a row is inserted that matches this query, a trigger is
fired.
>
> Cheers,
> Tom
>
>
Oracle already has something of that nature -- they're called INSTEAD OF triggers and they are placed on views to allow inserts, updates and deletes on the underlying tables of a view. Per the Oracle documentation:
INSTEAD OF Triggers
INSTEAD OF triggers provide a transparent way of modifying views that cannot be modified directly through DML statements (INSERT, UPDATE, and DELETE). These triggers are called INSTEAD OF triggers because, unlike other types of triggers, Oracle fires the trigger instead of executing the triggering statement.
You can write normal INSERT, UPDATE, and DELETE statements against the view and the INSTEAD OF trigger is fired to update the underlying tables appropriately. INSTEAD OF triggers are activated for each row of the view that gets modified.
Modifying Views
Modifying views can have ambiguous results:
Object views present additional problems. For example, a key use of object views is to represent master/detail relationships. This operation inevitably involves joins, but modifying joins is inherently ambiguous.
As a result of these ambiguities, there are many restrictions on which views are modifiable (see the next section). An INSTEAD OF trigger can be used on object views as well as relational views that are not otherwise modifiable.
Even if the view is inherently modifiable, you might want to perform validations on the values being inserted, updated or deleted. INSTEAD OF triggers can also be used in this case. Here the trigger code would perform the validation on the rows being modified and if valid, propagate the changes to the underlying tables.
INSTEAD OF triggers also enable you to modify object view instances on the client-side through OCI. To modify an object materialized by an object view in the client-side object cache and flush it back to the persistent store, you must specify INSTEAD OF triggers, unless the object view is inherently modifiable. However, it is not necessary to define these triggers for just pinning and reading the view object in the object cache.
So, maybe this is what you are looking for.
-- David Fitzjarrell Oracle Certified DBA Sent via Deja.com http://www.deja.com/ Before you buy.Received on Fri Oct 27 2000 - 09:38:33 CDT
![]() |
![]() |