Developing Apama Applications > Apama EPL Reference > Statements > Compound statements > The from statement
The from statement
The from statement is used to create a stream listener. A stream listener watches for items from a stream and passes output items to procedural code.
A from statement is similar to an on statement, which listens for events processed by the correlator and then executes an event listener action for each matching event or pattern. See The on statement.
FromStatement
Rule components
You can assign the result of a from statement to a listener variable. This lets you call quit() on the stream listener.
A stream listener passes output items from a stream to procedural code. The stream, specified in Expression, can be a reference to an existing stream or a stream source template. Alternatively, it can be the stream created by an in-line stream query.
A colon and an identifier follow the Expression or in-line stream query. This signifies a coassignment — when new items are available from the stream, the stream listener coassigns each output item to the specified variable.
The statement following the identifier can be a single EPL statement or a block of EPL statements. The from statement passes the output item to this statement or block and executes the statement or block once for each output item. If the output of the query is a lot that contains more than one item, and you want to execute the statement or block just once for the lot, coassign the output to a sequence. See Developing Apama Applications in EPL, Working with Streams and Stream Queries, Working with lots that contain multiple items.
Copyright © 2013 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors.