Apama Documentation : Developing Apama Applications : Developing Apama Applications in EPL : Working with Streams and Stream Queries : Defining stream queries : Linking stream queries together
Linking stream queries together
A stream query definition is an expression and its result is a stream. Consequently, with one exception described below, you can use a stream query definition anywhere that you can use a stream value. For example, you can assign the resulting value to a stream variable:
stream <float> values := from a in sA select a.value;
Alternatively, you can use a stream query definition as the return value from an action, for example:
action createPriceStream (stream<Tick> ticks) returns stream<float> {
return from t in ticks select t.price;
}
Another option is to embed a stream query within another stream query, for example:
float vwap;
from p in (from t in ticks where t.price > threshold select t.price)
within period
select wavg(t.price,t.volume): vwap {
   processVwap(vwap);
}
You can use stream variables to link stream queries together, as detailed in the next section.
The exception is that you cannot use a stream query immediately after the from keyword in the first form of the from statement. For example, the following is not a valid statement:
from from t in ticks select t.price : tickPrice {
   print tickPrice.toString();
}
Instead, use the second form of the from statement and specify a stream variable or a stream source template. The following example specifies a stream variable:
from t in ticks select t.price : tickPrice{
   print tick.price.toString();
}
Copyright © 2013-2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback