Perform event addition, update, and deletion operations on a named window as a batch when an event occurs.
Syntax:
on eventType[(filterCondition)] [as name]
merge [into] windowName [as name]
[where conditionExpression]
when [not] matched [and condition]
then (
insert [into insertDefinition]
select propertyAndExpressionList
[where conditionExpression]
|
update set property = expression [,property = expression] [, ...]
[where conditionExpression]
|
delete
[where conditionExpression]
)
[then (insert|update|delete) ...] [then ...]
[when ... then ...] [...]
This syntax executes various types of operations on the named window specified at windowName when an event of eventType occurs.
The THEN clause action (INSERT, UPDATE, DELETE) specified after "when matched" or "when not matched" is executed in accordance with whether or not events are in the named window (or, if there is a WHERE clause specified after the MERGE clause, in accordance with that conditionExpression). A further condition can be added to "when [not] matched" by using AND. With "when matched", either INSERT, UPDATE, or DELETE can be specified as the THEN clause action. With "when not matched", only INSERT can be specified.