User Tools

Site Tools


adm14_triggers.htm
Navigation:  Dictionary Editor >====== Dictionary Triggers ====== Previous pageReturn to chapter overviewNext page

The Triggers interface of the Dictionary Editor allows you to enter Clarion source that can be applied before or after any data operation is performed on a selected table.

NoteBox.jpg

In the new Dictionary Explorer, triggers attached to any table are indicated by the following special icon:

Triggers.jpg

A trigger can include any Clarion language statement to execute as a unit and can also invoke stored procedures defined in your application. However, procedures and triggers differ in the way that they are invoked. A procedure is explicitly executed by a user, application, or trigger. Triggers (one or more) are implicitly fired (executed) by the supported database when a triggering INSERT, UPDATE, or DELETE statement is issued, no matter which user is connected or which application is being used.

A Data button is also available on this window. The data elements that you add here apply to all trigger types created for the selected table.

Uses of Triggers

Triggers can supplement the standard capabilities of a database to provide a highly customized database management system. For example, a trigger can restrict operations against a table to those issued during regular business hours. A trigger could also restrict operations to occur only at certain times during weekdays. Other uses for triggers are to

·automatically generate derived column values

·prevent invalid transactions

·enforce referential integrity across nodes in a distributed database

·enforce complex business rules

·provide transparent event logging

·maintain synchronous table replicates

·gather statistics on table access

·store complex computed and conditional fields that are table related in one location

Triggers are an extremely powerful tool, but you need to spend some time planning the use of triggers. Consider that when a trigger is executed, if your trigger code accesses another table(s) that a table access statement can cause execution of another trigger(s).

You can define a ROUTINE in a trigger with the following caveat; your ROUTINE's label must not start with the word “routine”. During code generation after the first ROUTINE is found code output from the templates resumes at column 1 only after the RETURN keyword is encountered.

See Also:

Trigger Properties

Dictionary (Client-Side) Triggers

adm14_triggers.htm.txt · Last modified: 2021/04/15 15:56 by 127.0.0.1