Skip to main content

Foreach (Trigger Keyword)

Controls when the trigger is fired.

Usage

To specify when the trigger is fired, use the following syntax:

Trigger name [ Event = sqlevent, Foreach = foreach ]  {    //implementation }

Where foreach is one of the following values:

  • row — This trigger is fired by each row affected by the triggering statement. For row-level triggers, you can set the Language keyword to objectscript or python.

  • row/object — This trigger is fired by each row affected by the triggering statement or by changes via object access. For row-level triggers, you can set the Language keyword to objectscript or python.

    This option defines a unified trigger, so called because it is fired by data changes that occur via SQL or object access. In contrast, with other triggers, if you want to use the same logic when changes occur via object access, it is necessary to implement callbacks such as %OnDelete().

  • statement — This trigger is fired once for the whole statement. For statement-level triggers, you can set the Language keyword to objectscript or tsql.

Details

Controls when the trigger is fired.

Default

If you omit this keyword, the trigger is a row-level trigger.

Exception

Row-level triggers are not supported for TSQL.

Statement-level triggers are not supported for Python.

See Also

FeedbackOpens in a new tab