Versions Compared

Key

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

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

Instructions

  1. We can perform this action in two methods.
  2. Make sure that Prerequisites: Make sure the database connection is successful using the SQL for Confluence app app.
    1. Log into in to your Confluence instance as an administrator and navigate .
    2. Navigate to Image RemovedImage Added(Cog wheelCogwheel) > Manage apps.
    3. From the left sidebar, select Select the SQL app > View and modify data source profiles and  from the left sidebar and ensure that connection to the database is successful.
      Image Removed
      Image Added
  3. 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 is used.
    Image RemovedImage Added
    Image RemovedImage Added
  3. Take Copy the storage of the page:
    Image Modified
    Image RemovedImage Added
  4. Navigate to Settings>General Configuration>User Settings > General Configuration > User Macros and click click the Create a User Macro link to create a new user macro.
    Image Modified
  5. Fill in the required parameters and Categories and Categories as per the requirement.
  6. Insert the storage format in the Template and saveclick 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 click the Create a User Macro link to create a new user macro.
    Image Modified
  2. Fill in the required parameters and Categories and Categories as per the requirement.
  3. In Enter the Template section fill the SQL query including the output format and datasource details and save the macro.
    Image Removed
    Image Removedin the Template section, enter data source details, and click Save.
    Image Added
    Image Added
  4. Now use the user macro in the confluence page.
    Image RemovedImage Added

Output:

Image Modified