Developing Apama Applications > EPL Streams: A Quick Tour > Processing events using streams > Using compound stream queries
Using compound stream queries
The complete stream network for the example presented in the previous topics can be expressed as a single compound query:
01. TemperatureAndPressure tp;
02. from t in
03. from t in all Temperature(sensorId="T001") retain 3 select mean(t.temperature)
04. retain 1
05. from p in
06. from p in all Pressure(sensorId="P001") retain 3 select mean(p.pressure)
07. retain 1
08 select TemperatureAndPressure("S001",t,p) : tp {
09. print tp.toString();
10. }
Note that the item identifiers, t and p, in the from clauses for the inner queries use the same names as those in the outer queries. This does not cause any ambiguity because the scope of the item identifier in the inner query is restricted to the inner query, and within the inner query hides the name used in the outer query. Hence, the item identifier, t, in the inner query refers to Temperature events from the stream all Temperature(sensorId="T001"), whereas the item identifier, t, in the outer query refers to the float items produced by the inner query. Using the same identifier is a matter of style; different identifiers could be used if preferred (for example, avgT and t).
Copyright © 2013-2015 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.
Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.