• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Jasper Reports / iReports Dynamic Query

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
We've gotta get close enough to that helmet to pull the choke on it's engine and flood his mind! Or, we could just read this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic