Apama 10.3 | Apama Documentation | Connecting Apama Applications to External Components | Standard IAF Plug-ins | The Database Connector IAF Adapter (ADBC) | The ADBC Event application programming interface | Named queries | Creating named queries
Creating named queries
Each named query in the ADBC-queryTemplates-SQL.xml file is defined in an XML <query> element. Each <query> element has the following attributes:
*name — The name of the query.
*description — A short description of the query.
*implementationFunction — The substitution function that the adapter uses to process the named query. The substitution function allows you to specify tokens that are replaced by parameters with matching names.
*inputString — A string that contains the substitution tokens you want to replace with values specified as parameters.
A <query> element can also have one or more optional <parameter> child elements. Each <parameter> element has the following attributes:
*description — A short description of the parameter.
*name — The name of the parameter.
*type — The data type of the parameter.
*default — The default value of the parameter.
As an example, the following XML code in the ADBC-queryTemplates-SQL.xml file defines the pre-built findEarliest named query. The query returns the row with the earliest time.
description="Get the row with the earliest time."
inputString="select * from ${TABLE_NAME} order by ${TIME_COLUMN_NAME}
asc limit 1">
description="Name of a table to query"
description="Name of the time column"
* To create a named query
1. In the Project Explorer, expand the project's Adapters node and open the adapter folder.
2. Double-click the instance configuration file to open it in the adapter editor.
3. In the adapter editor, select the Advanced tab.
4. Click the ADBC-queryTemplates-SQL.xml file to open it.
5. Select the Design tab.
6. On the Design tab, right-click the namedQuery element and select Add Child > New Element.
7. In the New Element dialog, type query, then click OK. A new query row is added to the list.
8. For each of the four attributes (name, description, implementationFunction, inputString):
a. Right-click the query element you have added, and select Add Attribute > New Attribute.
b. In the New Attribute dialog, provide a Name and a Value for the attribute.
9. If you want the query to use input parameters, for each parameter:
a. Right-click the query element and select Add Child > New Element.
b. In the New Element dialog, type parameter, then click OK.
c. Create the following attributes for each parameter:
10. Save the project's version of the query template file.

Copyright © 2013-2018 | 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.