Restrictions on INSTEAD OF Triggers on Views
You must be either the owner of the view or have the DBA status to create an INSTEAD OF trigger on a view. The owner of a simple view (based on only one table) has Insert, Update, and Delete privileges. For information about the relationship between the privileges of the trigger owner and the privileges of other users, see Privileges to Execute Trigger Actions.
If multiple tables underlie a view, only the owner of the view can create a trigger, but that owner can grant DML privileges on the view to other users.
- You can define an INSTEAD OF trigger only on a view, not on a table.
- The view must be local to the current database.
- The view cannot be an updatable view WITH CHECK OPTION.
- No SELECT event or WHEN clause is valid in an INSTEAD OF trigger.
- No BEFORE nor AFTER action is valid in an INSTEAD OF trigger.
- No OF column clause is valid in an INSTEAD OF UPDATE trigger.
- Every INSTEAD OF trigger must specify FOR EACH ROW.
- Trigger routines called by INSTEAD OF triggers cannot reference savepoints.
A view can have any number of INSTEAD OF triggers defined for each type of event (INSERT, DELETE, or UPDATE).
The ON EXCEPTION statement of SPL has no effect when it is issued from the Action clause of an INSTEAD OF trigger.
Just as with triggers on tables, an INSTEAD OF trigger whose triggered action inserts a new serial value into a BIGSERIAL, SERIAL, or SERIAL8 column cannot update the sqlca.sqlerrd[1] field of the SQL Communication Area structure. The triggered INSERT operation can successfully increment the serial counter for the column, but the value of the sqlca.sqlerrd[1] field remains zero, rather than being reset to the serial value. The sqlca.sqlerrd[1] field can show the new serial value that you insert directly through an updatable view, but that field cannot show the action of an INSTEAD OF Insert trigger on a serial column.