aspose file tools*
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
Author

Jasper Reports / iReports Dynamic Query

Doug Sanders
Greenhorn

Joined: Apr 05, 2007
Posts: 1
Hi,

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:

SELECT * FROM TABLE WHERE COLUMN_NAME = $P{parameterName}

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 :

java.sql.SQLException:�[IBM][CLI�Driver][DB2/NT]�SQL0104N��An�unexpected�token�"END-OF-STATEMENT"�was�found�following�"EARCHRESULTS�WHERE�?".��Expected�tokens�may�include:��"<interval_qualifier>".��SQLSTATE=42601

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

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
Greenhorn

Joined: Jun 25, 2008
Posts: 5
HI,
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
Marshal

Joined: Mar 22, 2005
Posts: 42929
    
  68
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: http://aspose.com/file-tools
 
subject: Jasper Reports / iReports Dynamic Query