ON clause: Trigger syntax

Specifies the stream or named window in which the arrival of a row triggers the deletion of rows from a named window or the resetting of a variable state.

Syntax

ON name [ [AS] alias ]
Components

name

The name of a data stream or window.

alias

An alias for the data source.

Usage

This form of the ON clause appears as the first clause in a Delete statement, Set Variable statement, or Update Window statement. The ON clause specifies the name of a data stream or named window in which the arrival of a row is a trigger. When the clause is used in a Delete statement, the trigger prompts the deletion of rows from a specified named window. In a Set Variable statement, the trigger causes specified variables to be reset. In an Update Window statement, the trigger prompts existing rows in a named window to be updated or new rows to be inserted.

The optional WHEN clause can be used in conjunction with the ON clause to limit the conditions for the trigger.

The data stream or window specified in this form of the ON clause can include an alias specified with the syntax stream-or-window-name [AS] alias.

Use this alias to refer to the trigger data stream or window in the WHEN clause of a Delete statement or Update Window statement, as well as in the SET, WHERE, and OTHERWISE INSERT clauses of an Update Window statement.

See Also

Examples

The following example monitors for the arrival of a row in InStream. When the row arrives, window rows in MyWindow1 that have the same symbol as the arriving InStream row are deleted.

ON InStream
DELETE FROM MyWindow1
WHERE InStream.Symbol = MyWindow1.Symbol;

In the following example, the rows in StreamB are counted.

ON StreamB
SET message_count = message_count+1;