This section gives examples of writing queries using the features discussed so far.
This sample demonstrates how to write a simple query with input mappings.
Query ID : customerAddressSQL
SQL Statement : select * from Customers where contactLastName = ? and contactFirstName = ?
The following query needs two parameters for execution. The Input Mapping section is used to specify these input parameters.
Following sample shows how to query the Cassandra data source created in Cassandra and add output mappings to it.
Query ID : getUsers
Data Source : CassandraDatasource
CQL : select 'key', 'username', 'password' from USER
You can define how the output of this query looks by adding output mappings as follows:
This example shows how to use a results row namespace in output mappings. See Defining Namespaces for information on namespaces.
Following sample shows a query written for the RDF data source created in Resource Description Framework, which is based on a RDF resource hosted by NASA. This sample uses the following SPARQL query to extract aircraft information from the data source.
The input mapping section is used to specify parameters to the query. The above query extracts aircraft information according to the agency. Therefore, we add agency as an input parameter. Next, the output mappings are used to map the response to an output XML.
Following sample shows a query written for the Web data source created in Web Resource. When you add a query to a Web data source, you must enter a Scraper Variable. This scraper variable must be the same as the output name in the Web data source configuration, which returns the output from the configuration. In this example, the var-def name in the configuration is weatherInfo (
>). Therefore, the Web resource output variable name is also specified as weatherInfo as shown below:
It defines output mappings as follows to specify how the output looks like.