Versions Compared

Key

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

This article explains how to get the list of pages in confluence containing the SQL macro using the app SQL for Confluence (Pro Edition).

Instructions

Follow the steps:

  1. Login to the Confluence instance.
  2. Go to the required confluence page and edit the same.
  3. Select the Data source profile.
    a.If you are aware of
    Database profile names than add SQL macro and select the Data source profile as shown in the below image.

           Image Modified
         b. If you are not aware of the database profile name. Then
log in as Confluence Admin and follow the below steps: 
             - Go Log in as Confluence Admin and go to General Configuration.
             - Click on the app SQL for Confluence (Pro Edition) under Bob Swift Configuration.
             - Click on View on View and modify data source profiles tabprofiles tab.
                Image Added

      4. Run below SQL query to get the list of DB profiles created in your Confluence instance. In your SQL profile table, there will be number for this table so replace XXXX value with the number.

Code Block
languagesql
select profile_name from AO_xxxxx_SQLPROFILES;

        Image RemovedImage Added
        5. Click on Save setting to get the list of Database profiles from the above query.
       Image RemovedImage Added

      6. Replace the database profile name in place of Mysql_confluence in the below query to get the list of space details. Execute the below query for each of the database profile names.

Code Block
languagesql
SELECT c.title, s.spacekey FROM CONTENT c JOIN BODYCONTENT bc ON c.contentid = bc.contentid JOIN SPACES s ON c.spaceid = s.spaceid WHERE c.prevver IS NULL AND c.contenttype IN ('PAGE', 'BLOGPOST') AND bc.body LIKE '%ac:name="dataSource">Mysql_confluence%';

        Click on Save settings to save the SQL query.

Image Modified

...

7. Click on Save button on the page.
Image Added
8. This SQL query will list all the pages containing SQL macro in your confluence space.

Code Block
languagesql
Select CONTENT.CONTENTID, CONTENT.Title, CONTENT.SpaceID, CREATOR, LASTMODDATE from CONTENT, BODYCONTENT WHERE PREVVER IS NULL AND (CONTENT.CONTENTTYPE = 'PAGE' OR CONTENT.CONTENTTYPE = 'BLOGPOST') AND CONTENT.CONTENTID = BODYCONTENT.CONTENTID AND CONTENT.CONTENT_STATUS = 'current' AND (BODYCONTENT.BODY like '%<ac:structured-macro ac:name="sql"%');

 Click         Click on Save settings to save the SQL query.

Image Modified

9. Click on Save button on the confluence page to publish the page.
 Image Modified 


Info

Follow this link to configure Data source profile.