Skip to main content

Syntax of Triggers in Class Definitions

Describes the structure of a trigger definition. See Trigger Definitions for links to general information on defining triggers.


Triggers are code segments executed when specific events occur in InterSystems SQL. InterSystems IRIS supports triggers based on the execution of INSERT, UPDATE, and DELETE commands. The specified code will be executed either immediately before or immediately after the relevant command is executed, depending on the trigger definition. Each event can have multiple triggers as long as they are assigned an execution order.

You can add trigger definitions to persistent classes. They are not meaningful in other kinds of classes.


A trigger definition has the following structure:

/// description 
Trigger name [ keyword_list ]  
{ implementation }


  • description (optional) is intended for display in the Class Reference. The description is blank by default. See Creating Class Documentation.

  • name (required) is the name of the trigger. This must be a valid class member name, and must not conflict with any other class member names.

  • keyword_list (required) is a comma-separated list of keywords that further define the trigger.

    See Trigger Syntax and Keywords for a complete keyword list.

  • implementation (required) is zero or more lines of code that define the code that is to be executed when the trigger is fired.


/// This trigger updates the LogTable after every insert
Trigger LogEvent [ Event = INSERT, Time = AFTER ]
    // get row id of inserted row
    NEW id
    SET id = {ID}

    // INSERT value into Log table
    &sql(INSERT INTO LogTable (TableName, IDValue) VALUES ('MyApp.Person', :id))


See Also

FeedbackOpens in a new tab