## @param emptymsg: does not seem to work

I am trying to use the parameter to return some text if my query returns nothing, and it doesn't seem to be working. 

Query: 

select listagg(osuser, ', ') within group (order by osuser) as "plain" from (select distinct osuser from v$session) where osuser != 'SYSTEM' and osuser not like 'VMCONFTEST%'

Template: 

## @param emptymsg:The query returned no result!!
#foreach($row in $result)
$row.plain
#end

Result:

$row.plain

1 answer

Hi Phillip,

Do I understand you right that "$row.plain" is written on your page? This means that your result is not empty, but contains one row and apparently this row has no "plain" value. Please try with a simple statement that will always return an empty result:

SELECT *
FROM v$session
WHERE osuser = 'SomethingThatIsNoUsername'

Or something similar - just try a query whose result will be empty for sure.

And also try with a simple template like this:

## @param emptymsg:The query returned no result!!
 
This is just a test!

Regards, Felix

$row.plain is written on my page. It does work if I use your query suggestion, but I think it is when I use the listagg function that it doesn't work. 

When I take my exact query mentioned above and run it in my database, it returns a list of distinct users connected, and if none are connected, it returns nothing. 

I used the #foreach function to help get rid of some formatting

For analysis, please simply write $result and $result.size() in your template and let me know of the result.

$result gives me this:  [{plain=null}]

$result.size() gives me this: 1

It looks like your query is in fact returning one row in which the value for "plain" is null. $result is simply the result of your query. You'll have to find a way for your query to return truly an empty result set.

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...

77 views 0 5
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