Jump to content
We've recently updated our Privacy Statement, available here ×

Parameters in ORDER BY


sdemills

Recommended Posts

I'm a relative beginner with iReport. I've built a report with Parameters and they all work ok apart from the one in the ORDER BY clause which reads ORDER BY $P{pSequence} DESC, and more keys.

If I include the parameter in the report body then I can see that it is being set correctly.

If I edit its value into the SQL statement instead of using the Parameter substitution above, then I get the right results.

However if I use the substitution above then the sequence does not come out as desired. I can't tell yet whether that part of the ORDER BY is being ignored or whether the entire ORDER BY clause is being ignored. No error is reported and the report is generated ok but not in the desired sequence.

So given that the substitution is working in the report itself - I see the value printed out - and given that parameters used in the WHERE clause are working fine, why doesn't the parameter in the ORDER BY clause work?

Any ideas? Or worked examples where it does work?

Kind Regards
Steve

 

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

I don't know what is the exact content of your "$P{pSequence} but if there are strings, I fear that the expansion which takes care of type adds some quots.

Try using "$P!{pSequence} (notice the "!")which will expand the parameter as is.

Hope this helps

Link to comment
Share on other sites

That solved it. Thank you very much for the tip. I was just on the point of getting my calling Java program to read back the jrxml file and edit the query on the fly. That was a really useful tip and I've written it down for future reference.

Kind Regards

Steve

Link to comment
Share on other sites

  • 5 years later...
  • 8 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...