Versions Compared

Key

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

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

Instructions

  1. We can perform this action in two methods.
  2. Prerequisites: Make sure that the database connection is successful using the SQL for Confluence app.
    1. Log into in to your Confluence instance as an administrator and navigate .
    2. Navigate to (Cog wheelCogwheel) > 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.
      Image RemovedImage Added
  3. We can perform this action in two methods.
Expand
titleMethod 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 is used.
    Image RemovedImage Added
    Image RemovedImage Added
  3. Take the storage of the page:

    Image RemovedImage Added
  4. Navigate to Settings>General Configuration>User 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 and Categories as per the requirement.
  6. Insert the storage format in the Template and 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 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 datasource data source details, and save the macro.
    Image RemovedImage Added
    Image RemovedImage Added
  4. Now use the user macro in the confluence page.
    Image RemovedImage Added

Output: