Apama 10.15.0 | Developing Apama Applications | Developing Apama Applications in EPL | Working with Streams and Stream Queries | Using dynamic expressions in stream queries | Examples of using dynamic expressions in stream queries | Example of actions and methods in dynamic expressions
 
Example of actions and methods in dynamic expressions
Actions and methods can be considered to be dynamic elements. There are various reasons why you might want to use actions and methods in queries:
*If you are using a particular common complex expression in several places in queries within a monitor, it might be preferable to implement this as an action.
*If you are using a method that is implemented in a plug-in.
*To add protection to expressions that, if unprotected, might cause runtime errors. For example:
stream<Tick> basketPrices :=
   from p in prices
   partition by p.symbol
   retain 1
   select sum( p.price * getBasketVolume(t.symbol) );
...
action getBasketVolume( string symbol) returns float {
if ( basketVolume.hasKey(t.symbol) ) {
   return basketVolume[t.symbol];
} else {
   return 0.0;
}
}