How to Associate a Trigger with a File

Once you have written your trigger subroutine, you must associate it with the appropriate Reality file using the CREATE-TRIGGER command. You must specify the file, the trigger subroutine and the type of trigger required (for example: PRE-WRITE, POST-WRITE, PRE-DELETE or POST-DELETE). A trigger can be associated with a file data section or a file dictionary. Note that the trigger subroutine must be cataloged in the master dictionary of the account containing the file.

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. LIST-ALL-TRIGGERS lists the triggers associated with a Reality account.

Note

  • When accessing files in a different account on the same database (either by defined or direct Q-pointers), the trigger subroutine must be cataloged in the master dictionary containing the Q-pointer.

  • When accessing files in a different database, both the trigger definition and trigger subroutine must reside in the remote database where the file resides, not in the local database.

  • If a file is open, changes to its associated triggers will not take effect until it is closed and re-opened.

  • Only D-pointers can have trigger definitions; Q-pointers use the definition in the target D-pointer.

  • The first time a trigger subroutine is used after you have logged on or associated it with a file, it is copied into a local cache. Subsequent calls to the trigger are therefore much quicker because it is not necessary to fetch the trigger from disk. The cache is cleared when you log off, log to another account or catalog any DataBasic program.

    If the cataloged version is changed, only those processes that do not have the trigger cached will use the new version when the trigger next runs. Note that because the local cache is cleared when a DataBasic program is cataloged, the user that catalogs the new version of the trigger will use the new version immediately.

See also

Embedded Basic Subroutines
How to Write an Embedded Basic Subroutine
Embedded Basic Examples
Debugging Embedded Basic Subroutines
Triggers Dos and Don'ts