Help understanding SQL Plugin syntax within macro

I apologize in advance for the inane question, but I have been unable to figure this out on my own. I know it has to be something simple, but I am stuck. Any help would be greatly appreciated.

We have a space called "advancedfixtures". If I create a blank page and insert the following Wiki markup in it, the results are correctly displayed as a table:

{sql:datasource=Vipre}select * from kaseya_combined where groupname like '%advancedfixtures%' {sql}

However, if I try to move this code to a macro and insert the macro in a Wiki page, I get nothing back:

## @noparams
select * from kaseya_combined where groupname like '%advancedfixtures%' 

Ideally, I would like to create a generic macro that can be used in all spaces, where the spacekey gets inserted into the SQL query:

## @noparams
#set($spacekey= $paramspacekey)
## Check for valid space key, otherwise use current
#if (!$spacekey)  
   #set ($spacekey=$space.key)
select * from kaseya_combined where groupname like '%$spacekey%' 

Thanks in advance,

Jim Lancaster
Dallas, TX

3 answers

Does the macro work if you take out the "like" clause? In other words, can we rule out the '%xxx%' syntax as the source of the issue?

In defining your user macro, choose

  1. no macro body
  2. Output format: wiki markup

If you have this, then put showSql=true in the macro to see the sql that is actually being used for the query.

I thought a screen shot of the user macro definition might be helpful:

No change. The wiki markup works, the macro doesn't. In the first screenshot below, note that the macro (JDL SQL Test) is inserted above the Wiki markup. In the next screenshot, you can see the macro gets interpretted as a text string, and the Wiki markup generates the correct table.

Nothing changed. To my untrained eye, it appears that the macro code that does not begin with '#' is being interpreted or converted to text. Could the problem be related to calling the sql macro from within my 'jdl-sql-test' macro?

Here is the current macro code:

## @noparams
#set($spacekey= $paramspacekey)
## Check for valid space key, otherwise use current
#if (!$spacekey)  
   #set ($spacekey=$space.key)
select * from kaseya_combined where groupName like '%advancedfixtures%'

The key is in your macro definition use: Output format: wiki markup

Am I using the wrong syntax for output format? I have "output=wiki" in both the screenshot above and the code example.


I am talking about your user macro definition.

How should I modify the 9 lines of macro code above? I can't find anything in the documentation--not even some example code.

Can you point me to something/anything where I could at least see a list of the possible commands and their use? I feel like I'm banging my head on a wall. And I hate bothering people with stupid questions I could answer for myself if I had access to documentation and/or example code.

A-ha, I think I've found a possible reason for our inability to communicate. The link below contains a discussion about a similar issue. In version 3.5, there is a drop down that allows you to specify the output format: HTML or Wiki. This drop down does not appear in version 4.2.

Ok, so that is why we are having trouble communicating. Yes, that is exactly what I was talking about. For 4.x, Atlassian seems to have removed that capability for new macros, although it is still there for existing macros. I have no idea why it was removed. I could not find documentation ( on how to accomplish the same. You probably need to render it. I would suggest asking Atlassian to respond to this question (use poke Atlassian).

Good suggestion, but that had no effect.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Tuesday in Confluence

Confluence Admin Certification now $150 for Community Members

More and more people are building their careers with Atlassian, and we want you to be at the front of this wave! Important Dates Start the Certification Prep Course by 2 April 2019 Take your e...

212 views 2 10
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you