SQL PLUGIN with run plugin

Christopher Dlugolinski April 11, 2013

Using the example from:

https://bobswift.atlassian.net/wiki/display/RUN/How+to+generate+choice+values+using+SQL

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 = """
{run:id=dynamic|autorun=true|replace=value:5::select::${choices}}
{sql-query:datasource=CORP\\\\dlugolinskic}
select * from TestDS where Field2 = \$value
{sql-query}
{run}
"""
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.

Thanks

1 answer

1 accepted

0 votes
Answer accepted
Bob Swift OSS (Bob Swift Atlassian Apps)
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.
April 11, 2013

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.

Christopher Dlugolinski April 16, 2013

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

thanks

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events