Queries define the way data is fetched from one of your datasources and made available within Confluence. Use the tabs on top to jump to the overview of "Queries". Again, you will find an empty list. Click "Add query" and set up your first query.
The most important fields, that we will use now, are:
- The datasource used. Depending on the type of the datasource, the form will adjust as an SQL statement needs different parameters than a REST call.
- The name of the query. It must only contain letters, numbers, hyphens and underscores. Once set and saved, it cannot be changed anymore.
- The statement, i.e. the SQL statement itself. In our example, we will retrieve all countries on the continent 'Europe'.
As you can see, there are more features available which are described in the documentation. For now, simply click "Ok" to save. Your first query is now ready to go!
Use the PocketQuery Macro
Go to any Confluence page in any space you like and edit it. Add the PocketQuery Macro to it, either by clicking the plus icon from the toolbar and selecting "Other macros" or by typing an opening curly bracket followed by "pocketquery".
A dialog opens that allows you to set the macro parameters. From the dropdown "Query name" select the query we just created in the administration. You can use the preview feature if you like, or simply add the macro right away by clicking "Insert".
Save the Confluence page and have a look at the big table the PocketQueryMacro displays. This data comes straight from the "world" database!