Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » change report query based on connected database
change report query based on connected database [message #721756] Fri, 02 September 2011 14:23 Go to next message
Alessio Pollero is currently offline Alessio Pollero
Messages: 65
Registered: August 2011
Member
I'm developing some report with BIRT, each report have a Dataset with an SQL query inside, then from my Java application through Report Engine API i pass the JDBC connection object with a code like this :

task.getAppContext().put("OdaJDBCDriverPassInConnection", this.conn.getConnection()); 


The database connection that the java application pass to the report task could be linked to different database server (mainly MySQL, PostgreSQL and Sql Server ), since some query are quite complex some times i need to change some expression in the query based on the database server type linked by the connection because the syntax can vary from database server to database server ...

Is there a way for change the entire query or a part of it based on the database server type linked to the connection ?

How can i do it ?
Can i modify the query directly in the report event with JavaScript ?


Thanks.
Re: change report query based on connected database [message #722200 is a reply to message #721756] Sun, 04 September 2011 23:38 Go to previous messageGo to next message
sam va is currently offline sam va
Messages: 121
Registered: July 2011
Senior Member
If you are not a java person I am not sure if you like this.
But there are already java frameworks available to cater to this need. Eg: Hibernate. You can use hibernate to run your query, and have a scripted dataset to render in your report.

Thanks
Re: change report query based on connected database [message #722676 is a reply to message #722200] Tue, 06 September 2011 09:56 Go to previous message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Also in the beforeOpen script of the data set you can alter the query.
For example suppose your query was select * from orderdetails. You
could add a where clause like

this.queryText = this.queryText + " where ordernumber = 10101";

Jason

On 9/4/2011 11:38 PM, sam wrote:
> If you are not a java person I am not sure if you like this.
> But there are already java frameworks available to cater to this need.
> Eg: Hibernate. You can use hibernate to run your query, and have a
> scripted dataset to render in your report.
> Thanks
Previous Topic:connetion profile proplem
Next Topic:BIRT Cross Tab
Goto Forum:
  


Current Time: Fri Aug 01 18:37:45 EDT 2014

Powered by FUDForum. Page generated in 0.01619 seconds