SQL PLUGIN with run plugin

Using the example from:


I get the following error:

sql-query: java.sql.SQLException: Incorrect syntax near '|'.

this is the groovy script file:

import com.atlassian.renderer.v2.RenderMode;
import com.atlassian.renderer.v2.RenderMode

def renderMode = RenderMode.suppress(RenderMode.F_FIRST_PARA)
def choiceSql = "SELECT distinct(Field2) || ':' || 'Report ' || Field2 || ':' as choice FROM TestDS"
def choiceMacro = "{sql-query:datasource=CORP\\\\dlugolinskic|table=false} ${choiceSql} {sql-query}"
def choices = subRenderer.render(choiceMacro, context, renderMode)
def runMacro = """
select * from TestDS where Field2 = \$value
println runMacro

I have a database on the machine CORP\dlugolinskic and the table name is TestDS it has 2 fields, Field1 and Field2. Field1 is char, Field2 is int. it has some data in it.

I also tried to just use the text above in the groovy plugin window and got the same problem...

These escaping characters in this whole confluence software is crazy!! as it seems to not know how to concatinate?

what to do? I have never seen the || operation on an sql statement before.


1 answer

1 accepted

You need to make sure the SQL you produce is compatible with the database you are talking to. Likely you will need to use the concat function if || is not valid.

This is the correct conclusion for MS SQL needed to use '+' for concat.


Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

359 views 0 6
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