This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jasper Reports / iReports Dynamic Query

 
Doug Sanders
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic