gest Posted August 28, 2009 Share Posted August 28, 2009 Hello,I am facing a problem with setting the query for my subreport at runtime. I have to be able to change the 'order by'-clause for the subreport-query at runtime (in java application).Doing this for my master-report goes very well.Does anyone have an idea how to do this?I know it can be done with parameters, but I have to be able to set the order by clause of the subreport's query likeorder by col1 desc, col 2 col3 ascor order by col2 asc, col1 desc, col2 ascthe table will always be the same and the returned colums from the query too... gr Geert Post Edited by gest at 08/28/2009 12:48Post Edited by gest at 08/28/2009 12:49 Link to comment Share on other sites More sharing options...
JSquire Posted August 28, 2009 Share Posted August 28, 2009 try a CASE statement in the order by clause of your query - this is dependant on the database and version of SQL.just google 'SQL CASE statement' for examples Link to comment Share on other sites More sharing options...
gest Posted August 28, 2009 Author Share Posted August 28, 2009 Hello JSquire,thanks for your reply, haven't thought about doing that...I'll try it the first thing monday morning at work.grtz Link to comment Share on other sites More sharing options...
gest Posted August 31, 2009 Author Share Posted August 31, 2009 After doing some test on Oracle with a sql-statement that has a CASE-statement in the Order-By-clause, I haven't yet found a solution.My problem is that I have to be able to set the order-by as for example column1 asc or column2 desc, ... gr geert Link to comment Share on other sites More sharing options...
C-Box Posted September 1, 2009 Share Posted September 1, 2009 What about passing the whole orderby clause as parameter and just use.. ... ORDER BY $P!{SubReportOrderClause}within the SubReport Query hthC-Box Link to comment Share on other sites More sharing options...
gest Posted September 1, 2009 Author Share Posted September 1, 2009 Hey,solved my problem by using a case-structure in the order-by of my queryorder by case when par=? then ... end desc, when par=? then ... end asc, col3, col2 ... gr gest Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now