Documentation Comments
Use this form to comment on this topic. You can also provide any general observations about the Online Documentation, or request that additional information be added in a future release.
RealityV15.1Online Documentation (MoTW) Revision 7
File Triggers (m605006_filetriggers.htm)
A file trigger is a cataloged subroutine that is called automatically whenever an item is written to or deleted from a particular file. A trigger can be set to run before or after an item is written and before or after an item is deleted.
Note that file triggers do not run during restore operations.
The section File Triggers in the DataBasic Reference describes how write a trigger.
Once a trigger has been written, it will need to be associated with the appropriate Reality file. To do this, use the CREATE-TRIGGER command; you must specify the name of the file, the name of the trigger subroutine and the type of trigger required (PRE-WRITE, POST-WRITE, PRE-DELETE or POST-DELETE). Note that the trigger subroutine must be cataloged in the master dictionary of the account containing the file. A trigger can be associated with a file data section, a file dictionary or an account's master dictionary.
Caution
When associating a trigger with a file, you need to be aware of the effects of any other triggers that might run as a consequence.
The DELETE-TRIGGER command allows you to remove trigger associations. In this case you need only specify the file name and the trigger type.
LIST-TRIGGERS lists the triggers associated with a file.
Note: It is strongly recommended that triggers should not be associated with system files.
When running any command that updates a file, you should be aware of the effects of any file triggers that might be run as a consequence. For example, the following commands can cause triggers to be executed (the list is not exhaustive).
BASIC(writes a $ item)
COPY (trigger on destination file)
DELETE
EDELETE
ED{IT} (see EDITOR Commands below)
SE{D{IT}} (see Screen Editor Commands below)
SQL (update commands)
F-DELETE
F-WRITE
FD
FI
FS
F
You should also be aware that, if you place triggers on DICT sections or an account's MD, many more commands might cause these triggers to run. For example:
CATALOG
CREATE-FILE
CREATE-INDEX
DELETE-FILE
DELETE-INDEX
Note that the DataBasic write and delete statements can also cause triggers to run. Refer to the DataBasic Reference for details.