Skip to main content

Foreach

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. Note that row-level triggers are not supported for TSQL, so that the setting of the Language keyword must be cache.

  • row/object — This trigger is fired by each row affected by the triggering statement or by changes via object access. Note that row-level triggers are not supported for TSQL, so that the setting of the Language keyword must be cache.

    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. Statement-level triggers are supported for both ObjectScript and TSQL; that is, the setting of the Language keyword can be cache or tsql, respectively.

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.

See Also

FeedbackOpens in a new tab