0

I want to change ORDER BY statement in a jrxml

for example

SELECT * FROM table WHERE Id = 1 ORDER BY Name ASC

How to change ASC dynamic?

I tried below , but it's not work

SELECT * FROM table WHERE Id = $P{Id} ORDER BY Name $P{OrderType}
EXEC sp_executeSQL 'SELECT * FROM table WHERE Id = $P{Id} ORDER BY Name $P{OrderType}'

I have to change it in jrxml, so I cant use code like c# or java.

Alex K
  • 22,315
  • 19
  • 108
  • 236
Vincent
  • 81
  • 6
  • Try to use `$P!{OrderType}`. Sample: ` <![CDATA["ASC"]]> <![CDATA[SELECT id, name FROM product ORDER BY name $P!{order}]]> ` – Alex K Jun 23 '14 at 10:01
  • Thinks it's worked ,please answer the question , I will choose your answer. – Vincent Jun 24 '14 at 05:44
  • You can upvote my answer on [JasperReports: Passing parameters to query](http://stackoverflow.com/q/11871042/876298()) if you want :) Your post duplicates this question. – Alex K Jun 24 '14 at 06:15

0 Answers0