Connecting Apama Applications to External Components > Using Standard Adapters > Using the Apama Database Connector > The ADBCHelper Application Programming Interface > Handling query results for event data
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 on using the Visual Mapper, 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...
}
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.