Apama 10.3.1 | Apama Documentation | Developing Apama Applications | Developing Apama Applications in EPL | Defining Queries | Finding and acting on event patterns | Defining actions in queries
 
Defining actions in queries
In a query, after a find statement, you can define one or more actions in the same form as in EPL monitors. See Defining actions.
In a given query, an action that you define can be referenced from any expression in that query's find statement, including any statements in its find block. For example:
query CallingQueryActions {
parameters {
float distanceThreshold;
float period;
}
inputs {
Withdrawal() key account within period;
}
find Withdrawal as w1 -> Withdrawal as w2
where distance(w1.coords, w2.coords ) > distanceThreshold
{
logIncident( w1, w2 );
sendSmsAlertToCustomer(
getTelephoneNumber(w1), getAlertText(w1,w2) );
}

action distance( Coords a, Coords b) returns float {
integer x := a.x - b.x;
integer y := a.y – b.y;
return ( x*x + y*y ).sqrt();
}

action logIncident ( Withdrawal w, Withrawal w2 ) { ... }
action getTelephoneNumber(Withdrawal w ) returns string { ... }
action getAlertText ( Withdrawal w1, Withrawal w2 ) returns string { ... }
action sendSmsAlertToCustomer( string telephoneNumber, string text ) { ... }
}
Note: In a query, do not define an action whose name is onload, ondie, onunload, onBeginRecovery, or onConcludeRecovery. In EPL monitors, actions with these names have special meaning. For more information, see Monitor actions.

Copyright © 2013-2019 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.