Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Usq sql within a user macro with the sql dynamically constructed

Christophe Bonvin October 9, 2019


I would like to have a usermacro, taking the name of the page and constructing a sql statement that I could pass to the sql macro.

The outline is : 


#set ($query = "select field1, field2 from somtable where field1 ="+$content.getTitle())

<ac:structured-macro ac:macro-id="f9f4ee50-2e49-463a-8ab5-79cd170f1450" ac:name="sql-query" ac:schema-version="1">
<ac:parameter ac:name="dataSource">mysource</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:parameter ac:name="table">false</ac:parameter>



How do I substitue my $query in the macro ?


Thank you





2 answers

0 votes
Avinash Bhagawati _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 10, 2019

Hi @Christophe Bonvin ,

Thanks for raising your query through Atlassian Community and we have raised to support request from our end and please sign up to portal to view the support request.

With the help of Run Macro from Run Self Service Reports app you will be able to configure pre-defined variables  for $page_title and the SQL macro needs to be embedded within Run Macro.

Please find below screenshot for your reference and please note that in below screenshot $page_title will be substituted in SQL macro.

image (2).pngThanks,


Simon Degiorgi
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 21, 2024

Hi @Avinash Bhagawati _Appfire_ We use SQL for Confluence (Pro Edition) and would like to ask if we can achieve the same thing or if we need Run Macro as well. We are trying to make a SQL Query and use our Confluence page title in the query.

0 votes
JP _AC Bielefeld Leader_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 9, 2019


are you sure there is a "SQL Query" marco in standard Confluence? I'm not sure about that.



Christophe Bonvin October 9, 2019


The issue is not with the sql macro, which is not part of confluence, but provided by Bob Swift from Appfire as a very useful plugin.

The issue is how to pass a variable into CDATA[...] for rendering. With the "old" wiki markup, it was possible to use something like



#set ($runMacro =" {sql-query:datasource=source}select somestuff from sometable{sql-query}")



I do not know how to do that with the new format.




Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events