Skip to main content
Skip table of contents

How to use parameters in queries

It is possible to use parameters in queries to make them more flexible and versatile. Parameter values can be set when adding the PocketQuery macro to a Confluence page.

Parameters are included within the Statement (for SQL datasources) or REST URL (for REST datasources) and are marked by a leading colon. A simple SQL example could be:

CODE
SELECT Name, Population
FROM Country
WHERE Continent = :continent

When executing the query, the parameter is replaced with the value set by the user, e.g. "Europe":

CODE
SELECT Name, Population
FROM Country
WHERE Continent = 'Europe'

For SQL queries, it is also possible to choose the type of the parameter, which changes the way it is embedded into the query. For example, strings are enclosed by quotes while integers are inserted without quotes and lists are handled completely different. For a detailed explanation of the parameter types, please refer to the corresponding section within the PocketQuery Documentation.

Additionally, it is possible to allow users to change the parameters without editing the page (using the option "Change params template") or to set the parameters dynamically via URL. For more information on that, please refer to the Documentation of the PocketQuery Macro

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.