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 20 Next »

This article explains how to use SQL macro of the SQL for Confluence app in a user macro section of Confluence. This article presents 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. Select the SQL app > View and modify data source profiles from the left sidebar and ensure that connection to the database is successful.

  2. You can perform this action using 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. Copy the storage of the page:

  4. Navigate to Settings > General Configuration > User Macros and click the 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 click Save.
  7. Now use the user macro in the confluence page.

Output:

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

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

Output:

  • No labels