Apama 10.7.2 | Using Apama with Software AG Designer | Using the Data Player | Creating Data Player query templates
 
Creating Data Player query templates
If you want to create a new Data Player query template, you need to specify them in the project's query template file. The Data Player query template file is found in the project's bundle_instance_files folder and is named ADBC-queryTemplates-SQL.xml if you are using an ODBC or JDBC data source or ADBC-queryTemplates-Sim.xml if you are using a Sim data source.
*To add a Data Player query template
1. In the Project Explorer view, expand the project's bundle_instance_files folder and then expand either the ADBC_for_ODBC, ADBC_for_JDBC, or ADBC_for_Sim folder as appropriate.
2. Double click the query templates file, either ADBC-queryTemplates-SQL.xml or ADBC-queryTemplates-Sim.xml. The file opens in the text editor. The following is the standard findLatest Data Player query template for ODBC and JDBC data sources.
<query
  name="findLatest"
  description="Get the row with the latest time."
  implementationFunction="substitution"
  inputString="select * from ${TABLE_NAME} order by
         ${TIME_COLUMN_NAME} desc limit 1">
    <parameter
      description="Name of a table to query"
      name="TABLE_NAME"
      type="String"
      default=""/>
    <parameter
      description="Name of the time column"
      name="TIME_COLUMN_NAME"
      type="String"
      default="timeField"/>
</query>
3. The Data Player query templates are defined in the <query> element. The available attributes you can specify are:
*name — A short name that will be displayed in the Query Template drop-down list.
*description — A short description of the Data Player query.
*implementationFunction — Currently Data Player query templates support the substitution function. This allows a token to be used as a place holder in a SQL query.
*inputString — For ODBC and JDBC data sources, use standard SQL syntax, from the example above:
inputString="select * from ${TABLE_NAME} order by
     ${TIME_COLUMN_NAME} desc limit 1">
In the above example, $(TABLE_NAME) and $(TIME_COLUMN_NAME) are parameters that will be replaced with a database table and column name when you create a Data Player query from the template (see parameter, below).
For Sim data sources use the TIME keyword plus the comparators =, &gt;&lt;&gt;=, &lt;= plus the time. You can use one or two TIME expressions. Note, because you are adding the expression to an xml file, you need to use &gt; and &lt; instead of the characters > and <. Do not use spaces before or after &gt; and &lt;.
The inputString expression can also use the INCLUDE, and EXCLUDE keywords, for example:
TIME=12345;INCLUDE=(com.apama.something);EXCLUDE=(com.apama.something.abc)
TIME&gt;12345;TIME&lt;20000
*parameter — For ODBC and JDBC data sources you can specify parameters and default values for the Data Player query template. This allows you to create different Data Player queries from the same template that, for example, query different tables or different columns in the database. From the above example:

<parameter
  description="Name of a table to query"
  name="TABLE_NAME"
  type="String"
  default=""/>
<parameter
  description="Name of the time column"
  name="TIME_COLUMN_NAME"
  type="String"
  default="timeField"/>
When you create a Data Player query from a template that has the parameters shown above in the Data Player Query Editor, you will specify the names of the database table and column to use with the Data Player query.
4. Save the Data Player query template file when you finish modifying it.