Deploying and Managing Apama Applications > 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 Studio's Visual Mapper, 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 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.