Pass Optional parameter in Report
#1
Posted 19 September 2010 - 09:46 PM
I am new to birt, I have made reports which 4 to 6 parameter and i have integrated the report in jsp .
I am using hibernate connection for database
all thing are working well .But the problem i want to pass optional parameter to report .how can i do this staff
I have changed the Parameter and have unchecked IsRequired but Still it not working. it doesn't take any null value and throw error
and then tried it writing Dynamic Query in database Script on BeforeOpen but still it no working
Please somebody help me
sorry for poor english
Thanx
#2
Posted 24 September 2010 - 10:46 AM
If you make the parameter optional, you'll need to add the portion of your where statement that uses this parameter using script. In your beforeOpen method of your dataSet, you'd use a statement like:
if (params["paramName"] != null){
this.queryText = this.queryText + " where dbTable.dbStringField = '" + params["stringParam"] + "'";
}
If it's an integer or float value, you wouldn't need the single tick quotes(') surrounding the parameter value.
Hope this helps.
#4
Posted 24 September 2010 - 08:08 PM
The parameter doesn't take null value
i am using hql query like this
hql query + where invoiceDate between ? and ?
where invoiceDate is field of my Database
For the above problem i am providing default parameter with wide range of Date if user does not input any Date
Is ther any other way to do this stuff ?
Sorry for poor English
thanks
#5
Posted 27 September 2010 - 10:51 AM
#11
Posted 25 February 2011 - 08:44 AM
Hope this helps.
#18
Posted 09 September 2011 - 07:35 AM
select o.orders_id, o.orders_number, o.date_purchased, o.customers_name, o.customers_street_address, o.customers_city, o.customers_state, o.customers_postcode, o.customers_telephone, o.customers_email_address, op.products_id, op.products_name, opa.products_options_values_id, opa.products_options_values, ot.value from orders o inner join orders_products op on o.orders_id = op.orders_id left join orders_products_attributes opa on op.orders_products_id = opa.orders_products_id inner join orders_total ot on o.orders_id = ot.orders_id where o.orders_status = 5 and ot.class = 'ot_total' and o.date_purchased >= ? and o.date_purchased <= ?
Then, on the data set's 'beforeOpen' script, i have this:
if (params["productIdParam"] != null)
{
this.queryText += " and op.products_id = " + params["productIdParam"];
}
this.queryText += " order by op.products_id, opa.products_options_values_id, o.date_purchased;";
When I run this query, if I do not supply a product id, I get nothing back; contrarily, if I do enter a product id, the report runs just as expected. I cannot see anything that's wrong with what I've done, but obviously, something is. I've attached my report design file. Any help on this would be greatly appreciated, thanks.
Oh, also, I cannot get logging to work. I am using BIRT Report Designer (i.e. stand-alone - I think this is what the RCP refers to?), version 2.6.1. My goal would be to enable SQL logging so that I can see what BIRT is using to query the database; I would think this would help me debug these types of issues on my own. Again, any help with this would be great. Lastly, I have removed database connection details from the uploaded report, so just be aware of that.
Attached File(s)
-
OrdersByProductIDInDateRange-optional.rptdesign (67.38K)
Number of downloads: 10
#19
Posted 13 September 2011 - 11:59 AM
#20
Posted 08 May 2012 - 06:36 AM






MultiQuote






