Thread: Update Triggers accessing new values and intercepting.

Update Triggers accessing new values and intercepting.

From
"Larry Silvermintz"
Date:

Please help explain how to use triggers with LANGUAGE SQL to enforce assertions or complex schema-wide multiple-table constraints, firing “before ... on insert or update”.

Perhaps this is also a topic for the Documentation forum, as it doesn’t seem to be present in the current docs.

Are there functionalities only available in functions written in LANGUAGE SQL (my preference) or conversely, any which are unavailable when implementing the handler function with SQL?

* How can the function access the values from the triggering insert/update statement? 

* What does it mean to specify “RETURNS TRIGGER”?

* Specifically, Do I specify the return type (s) somehow? 

* How does one specify the values to be returned?

* HOw, based upon the outcome of the function, can the original statement’s values either be used to complete the insert/update, or else be discarded?

* Is there a way to generate an error message, like those reported when a regular check constraint is violated?

** Where can I find examples of such constraint-enforcing triggers implemented in Language SQL?

 

Most appreciatively,

Larry Silvermintz

LarryS@ucla.edu