Skip to end of banner
Go to start of banner

How to use SQL macro in a Confluence user macro

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 19 Next »

This article explains how we can use SQL macro of SQL for Confluence app in a user macro section of Confluence. In this article, we considered inserting a simple SQL statement in the user macro.

Instructions

  1. Prerequisites: Make sure the database connection is successful using the SQL for Confluence app.
    1. Log in to your Confluence instance as an administrator.
    2. Navigate to (Cogwheel) > Manage apps.
    3. From the left sidebar, select the SQL app > View and modify data source profiles and ensure that connection to the database is successful.

  2. We can perform this action in two methods.
 Method 1:
  1. Insert SQL macro.

  2. Enter the SQL statement as required. In this example, a query is used to retrieve data from the persons table.

  3. Take the storage of the page:

  4. Navigate to Settings → General Configuration → User Macros and click Create a User Macro link to create a new user macro.

  5. Fill in the required parameters and Categories as per the requirement.
  6. Insert the storage format in the Template and save.
  7. Now use the user macro in the confluence page.

Output:

 Method 2:
  1. Navigate to Settings → General Configuration → User Macros and click Create a User Macro link to create a new user macro.
  2. Fill in the required parameters and Categories as per the requirement.
  3. In the Template section, fill the SQL query including the output format and data source details, and save the macro.

  4. Now use the user macro in the confluence page.

Output:

  • No labels