Developing Apama Applications > Developing Apama Applications in EPL > Working with Streams and Stream Queries > Defining stream queries
Defining stream queries
A stream query operates on one or two streams to transform their contents into a single output stream. A stream query definition declares an identifier for the items in the stream so that the item can be referred to by the operators in the stream query. Here is a simple stream query definition:
stream<integer> ints := from a in sA select a.i;
When the correlator executes a statement that contains a stream query definition the correlator creates a new stream query. Each stream query has an output stream (the type of which might differ from that of the input stream).
A stream query definition is an expression that evaluates to a stream value. The value is a reference to the output stream of the generated query.
Following is an example of a simple stream query in a stream listener:
from a in sA select a.b : b {
   doSomethingWith(b);
}
The following table describes the user-defined parts of this stream listener. It is important to understand the distinctive role each one serves.
a
This is an identifier that represents the current item in the stream being queried. See Specifying input streams in from clauses.
sA
This variable represents the stream being queried.
a.b
This expression describes what each query result looks like. In this example, the query produces outputs from the b field of the events in the stream.
b
This is the variable that you coassign the query results to so that the correlator can use the query result in the stream listener's code block.
Copyright © 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.