com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links' is unknown.

Sample Queries

This section gives examples of writing queries using the features discussed so far.

Sample 1: Using input mappings in a query

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.

For information on adding validations to your input mappings, see Input Validators.

Sample 2: Adding output mappings to a query

Following sample shows how to query the Cassandra data source created in /wiki/spaces/DEL/pages/6258814 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:

Sample 3: Using a result row namespace

This example shows how to use a results row namespace in output mappings. See Defining Namespaces for information on namespaces.  

Sample 4: Querying a RDF data source

Following sample shows a query written for the RDF data source created in Exposing Relational Data in RDF Format, which is based on the added RDF file. This sample uses the following SPARQL query to extract movies information from the data source.

PREFIX cd: <http://www.popular.movies/cd#> 

SELECT ?title ?director ?year ?genre ?actor  
WHERE {    
      ?movie cd:title ?title.  
      ?movie cd:director ?director.  
      ?movie cd:year ?year.  
      ?movie cd:genre ?genre.  
      ?movie cd:actor ?actor. 
}

The input mapping section is used to specify parameters to the query. The above query extracts movie information according to the genre. Therefore, we add genre as an input parameter. Next, the output mappings are used  to map the response to an output XML.  

Sample 5: Querying a Web data source

Following sample shows a query written for the Web data source created in /wiki/spaces/DEL/pages/6258826. 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 (< var-def name = '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.  

Sample 6: Querying a google spreadsheet 

Given below are sample queries that can be written for a google spreadsheet datasource. Note that SQL queries of this type can only be used for a google spreadsheet if the Query mode is enabled for the datasource in the data service.

Sample 1:

SELECT customerNumber, customerName, phone, state, country
FROM customers

Sample 2:

INSERT INTO customers (customerNumber, customerName, contactLastName)
VALUES(?,?,?)

Sample 3:

UPDATE customers
SET contactFirstName=?, contactLastName=?
WHERE customerNumber=?

Sample 4:

DELETE FROM customers
WHERE customerNumber=?

You can also create new sheets in the Excel or drop existing sheets.

Sample 5:

CREATE SHEET ProductCategories (ProductCode, Category)

Sample 6:

DROP SHEET ProductCategories

com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links2' is unknown.