Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Dynamic where clause in report?(Dynamic where clause in report?)
Dynamic where clause in report? [message #631306] Wed, 06 October 2010 22:38 Go to next message
dash  is currently offline dash Friend
Messages: 20
Registered: August 2010
Junior Member
Hi,

Based on the user's inputs, the where clause may contain one or two conditions. Is it possible to have a dynamic where clause in the report's query?

For example, if customer name exists, the where clause will become
select * from customers
where customer_name = ?

if both customer name and phone number exist, the where clause will become

select * from customers
where customer_name = ? and customer_phone_number = ?

Thanks,
kenny
Re: Dynamic where clause in report? [message #631419 is a reply to message #631306] Thu, 07 October 2010 13:55 Go to previous messageGo to next message
Richard A. Polunsky is currently offline Richard A. PolunskyFriend
Messages: 199
Registered: July 2009
Location: Houston TX
Senior Member

Depending on your back-end database, I'd do something like the following:

where customer_name = ?
and
(customer_phone_number IS NULL or customer_phone_number = ?)

Some databases don't short-cut evaluation and that last clause may have to be written differently.
Re: Dynamic where clause in report? [message #631546 is a reply to message #631419] Thu, 07 October 2010 22:12 Go to previous messageGo to next message
dash  is currently offline dash Friend
Messages: 20
Registered: August 2010
Junior Member
Hi Rich,

Thanks for your reply. But, I'm looking for a way to dynamically add additional condition(s) to the where clause in the same report instead of depending on the DB engine.

do you know whether it's possible?

thanks,
kenny
Re: Dynamic where clause in report? [message #631562 is a reply to message #631306] Fri, 08 October 2010 01:22 Go to previous message
Richard A. Polunsky is currently offline Richard A. PolunskyFriend
Messages: 199
Registered: July 2009
Location: Houston TX
Senior Member

You can do pretty much whatever you want to the query text (not just the where clause) by clicking on the data set, going to the Script tab and going into the beforeOpen event. There should be a lot of examples of that in the BIRT communities, I'd search for beforeOpen or queryText.
Previous Topic:Newbie Test
Next Topic:Using RE API without birt installed on the server machine
Goto Forum:
  


Current Time: Sat Nov 29 08:01:13 GMT 2014

Powered by FUDForum. Page generated in 0.02353 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software