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 looking up values in a dictionary
 
Example of looking up values in a dictionary
The following statement shows a query that calculates the current value of a basket of stocks based on the most recent prices for those stocks. When using dictionaries in this way, be careful to ensure that all values used as keys are in the dictionary. A missing key value causes a runtime error and the correlator terminates the monitor instance. In the example, it is assumed that the prices stream was filtered to contain prices for only the stocks in the basket.
stream<Tick> basketPrices :=
   from p in prices
   partition by p.symbol
   retain 1
   select sum( p.price * basketVolume[t.symbol] );