Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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 Image RemovedImage Added(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.
      Image Modified
  2. You can perform this action using two methods.
Expand
titleMethod 1:
  1. Insert SQL macro.
    Image Modified
  2. Enter the SQL statement as required. In this example, a query is used to retrieve data from the persons table.
    Image RemovedImage Added
    Image RemovedImage Added
  3. Copy the storage of the page:
    Image Modified
    Image RemovedImage Added
  4. Navigate to Settings > General Configuration > User Macros and click the Create a User Macro link to create a new user macro.
    Image Modified
  5. Fill in the required parameters and Categories as per the requirement.
  6. Insert the storage format in the Template and click Save.
    Image RemovedImage Added
  7. Now use the user macro in the confluence page.
    Image Removed
    Image Added

Output:
Image RemovedImage Added


Expand
titleMethod 2:
  1. Navigate to Settings > General Configuration > User Macros and click the Create a User Macro link to create a new user macro.
    Image Modified
  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.
    Image Modified
    Image Modified
  4. Now use the user macro in the confluence page.
    Image Modified

Output:

Image Modified