Handling query results for event data
For query actions that return a result set in the form of events, your application needs to do the following.
1. Define an event type that represents the returned data.
2. Map the returned data to fields in the event type. The easiest way to do this is to use the Apama's Visual Mapper in Software AG Designer, which automatically saves the mapping information in a project file. For more information, see
Using the Visual Event Mapper. 3. Create a listener for the event type.
4. Execute a query that returns events.
For example, the following EPL code snippet defines an event, executes a query that returns data in the form of the defined event, and defines a listener for the defined event:
event NetworkInfo {
string network;
integer countrycode;
integer nid;
}
//...
com.apama.database.DBUtil db;
action onload() {
db.openQuickODBC("exampledb","thomas","thomas123",handleError);
db.doSQLEventQuery("SELECT * FROM network_info", NetworkInfo);
//...
}
on all NetworkInfo := netInfo {
// Code to do something with the returned event...
}