File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other JSE/JEE APIs and the fly likes Jasper Reports / iReports Dynamic Query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Jasper Reports / iReports Dynamic Query" Watch "Jasper Reports / iReports Dynamic Query" New topic

Jasper Reports / iReports Dynamic Query

Doug Sanders

Joined: Apr 05, 2007
Posts: 1

I desperately need help on the following problem, any advise would be greatly appreciated.

I am using iReports to define a number of reports to be initiated from Java calls within a web app.

What I need to do is use a dynamic where clause and a dynamic order by clause within a report. I so far have been using syntax such as:


and this works a treat. But what I need to do now is something along the lines of:

SELECT * FROM TABLE WHERE ${whereClauseAsParameter} ORDER BY $P{orderByAsParameter}

If I try to do the above then I get an error message :


Can anybody please shed any light on how I might be able to do this ?
Sanjeev Debnath

Joined: May 25, 2007
Posts: 16
This thing you can't do in iReport. You have to generate the jrxml code manually from the java program. First of all read the jrxml file by opening it in any text editor. You can see the various sections into that jrxml. Point out to the <queryString> tag. Just write your query into this place at run time and save your jrxml file. And then do what you want.
Bill attagasam

Joined: Jun 25, 2008
Posts: 5
I modify the query to be like this
SELECT * FROM TABLE WHERE $P{whereClauseAsParameter}

from ireport, but I didn't run the report in iREport

I invoked the report from web and I got error msg:
Caused by: java.sql.SQLException: ORA-00933: SQL command not properly ended

can someone please help me how to write dynamic query in jasper report...
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
Bill, you're better off starting a new thread than to resurrect an old thread that's not even directly related to your question.
And even better, start the thread in the "Other Open Source Projects" forum (instead of this one), because that's where JasperReport and iReport are discussed.
I agree. Here's the link:
subject: Jasper Reports / iReports Dynamic Query
It's not a secret anymore!