BIRT Exchange Forum: Pass Optional parameter in Report - BIRT Exchange Forum

Jump to content


 

BIRT Poll: To best make a table fill a pdf page before breaking (PL=page layout, PBI=page break interval) set:

PL: auto, PBI: 0PL: fixed, PBI: 0PL: auto, PBI: 1000000PL: fixed, PBI: 1000000
  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

Pass Optional parameter in Report Rate Topic: -----

#1 User is offline   Rajesh Kakawat Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 20
  • Joined: 17-July 10


Posted 19 September 2010 - 09:46 PM

Hi ,
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
0

#2 User is offline   mwilliams Icon

  • BIRT Guru
  • Icon
  • View blog
  • Group: Administrators
  • Posts: 12937
  • Joined: 16-May 08


Posted 24 September 2010 - 10:46 AM

Hi Rajesh007,

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.
Regards,

Michael

Twitter
Facebook
Blog
Yahoo: mwilliams_actuate@yahoo.com
Google: mwilliams.actuate@gmail.com
1

#3 User is offline   Rajesh Kakawat Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 20
  • Joined: 17-July 10


Posted 24 September 2010 - 08:02 PM

Thanks i have solved
but anyway thanks for precious reply
thank you very much
0

#4 User is offline   Rajesh Kakawat Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 20
  • Joined: 17-July 10


Posted 24 September 2010 - 08:08 PM

But i think dateTime does not work in this manner
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
0

#5 User is offline   mwilliams Icon

  • BIRT Guru
  • Icon
  • View blog
  • Group: Administrators
  • Posts: 12937
  • Joined: 16-May 08


Posted 27 September 2010 - 10:51 AM

With a date time parameter, you'll need to include the '' surrounding the parameter in your script and make sure that the dateTime value is entered in the correct format for your database. If you're doing optional parameters, you'll need to do what I described above if the user chooses to leave the parameter blank. If you want to put a default range in, you'll just add your where clause in script similar to the above script only with static values rather than a parameter. I can provide a simple example if needed. Just let me know your BIRT version if you'd like an example.
Regards,

Michael

Twitter
Facebook
Blog
Yahoo: mwilliams_actuate@yahoo.com
Google: mwilliams.actuate@gmail.com
0

#6 User is offline   Rajesh Kakawat Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 20
  • Joined: 17-July 10


Posted 30 September 2010 - 07:56 AM

hi,
Thanks for ur reply , i haven't that what u reply last time but i will surely going to try
I am using Birt 2.5 from eclipse openSource

thanx
0

#7 User is offline   mwilliams Icon

  • BIRT Guru
  • Icon
  • View blog
  • Group: Administrators
  • Posts: 12937
  • Joined: 16-May 08


Posted 30 September 2010 - 08:23 AM

Well, let me know if you get stuck and would like an example. :)

Good luck!
Regards,

Michael

Twitter
Facebook
Blog
Yahoo: mwilliams_actuate@yahoo.com
Google: mwilliams.actuate@gmail.com
0

#8 User is offline   shrif Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 9
  • Joined: 21-February 11


Posted 23 February 2011 - 11:29 PM

anyone can tell me about this problem i didn't understand what can i do
i make the report parameter and enter ? in the sql query what can i do else
please tell me .....
0

#9 User is offline   Rajesh Kakawat Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 20
  • Joined: 17-July 10


Posted 24 February 2011 - 08:15 AM

Above problem was related with dynamic query which was created according to parameter passed by the user.
If you writing simple query than you have to just put ? in sql query and create a parameter.
0

#10 User is offline   shrif Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 9
  • Joined: 21-February 11


Posted 24 February 2011 - 10:19 AM

but i want to know if i didn't entered value in the parameter the result should be all the data
how can i make it ??
please answer me and thanks for your reply
0

#11 User is offline   mwilliams Icon

  • BIRT Guru
  • Icon
  • View blog
  • Group: Administrators
  • Posts: 12937
  • Joined: 16-May 08


Posted 25 February 2011 - 08:44 AM

You could set up the basic select/from query in your dataSet. If a value is selected, you can add the where clause in the beforeOpen script of your dataSet. If no value is selected, you can not edit th queryText and the entire result set will be called. There is also the possibility that you can add "All" to your parameter list and make the parameter required so that the user either selects All or one of the individual parameters.

Hope this helps.
Regards,

Michael

Twitter
Facebook
Blog
Yahoo: mwilliams_actuate@yahoo.com
Google: mwilliams.actuate@gmail.com
0

#12 User is offline   shrif Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 9
  • Joined: 21-February 11


Posted 28 February 2011 - 12:44 AM

can u write to me an example show me how to do this in details please
thanks alot...
0

#13 User is offline   mwilliams Icon

  • BIRT Guru
  • Icon
  • View blog
  • Group: Administrators
  • Posts: 12937
  • Joined: 16-May 08


Posted 28 February 2011 - 07:48 AM

What is your BIRT version? I'll make a quick example.
Regards,

Michael

Twitter
Facebook
Blog
Yahoo: mwilliams_actuate@yahoo.com
Google: mwilliams.actuate@gmail.com
0

#14 User is offline   shrif Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 9
  • Joined: 21-February 11


Posted 28 February 2011 - 10:20 PM

my birt version GANYMEDE
thx for your reply...
0

#15 User is offline   mwilliams Icon

  • BIRT Guru
  • Icon
  • View blog
  • Group: Administrators
  • Posts: 12937
  • Joined: 16-May 08


Posted 02 March 2011 - 08:08 AM

Ok. Check out the attached report and let me know if you have questions.

Attached File(s)


Regards,

Michael

Twitter
Facebook
Blog
Yahoo: mwilliams_actuate@yahoo.com
Google: mwilliams.actuate@gmail.com
0

#16 User is offline   shrif Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 9
  • Joined: 21-February 11


Posted 02 March 2011 - 11:19 PM

thx for your reply that's help me alot
0

#17 User is offline   mwilliams Icon

  • BIRT Guru
  • Icon
  • View blog
  • Group: Administrators
  • Posts: 12937
  • Joined: 16-May 08


Posted 03 March 2011 - 07:21 AM

Not a problem. Always glad to help. Let us know whenever you have questions!
Regards,

Michael

Twitter
Facebook
Blog
Yahoo: mwilliams_actuate@yahoo.com
Google: mwilliams.actuate@gmail.com
0

#18 User is offline   DispatchMG Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 13
  • Joined: 08-September 11


Posted 09 September 2011 - 07:35 AM

I'm attempting to do the same thing as the original poster, but I have a slightly different issue. My query is as follows:

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)


0

#19 User is offline   mwilliams Icon

  • BIRT Guru
  • Icon
  • View blog
  • Group: Administrators
  • Posts: 12937
  • Joined: 16-May 08


Posted 13 September 2011 - 11:59 AM

You might try checking the parameter for an empty string value as well, i.e. "". One thing you can do to check your query text that is passed is to assign queryText to a variable in your beforeOpen script and then recall this variable in a text box in your report. I believe this will still show the '?' dataSet parameters, but it will show what is passed in the line in question from your beforeOpen script. So, that might help.
Regards,

Michael

Twitter
Facebook
Blog
Yahoo: mwilliams_actuate@yahoo.com
Google: mwilliams.actuate@gmail.com
0

#20 User is offline   ocremedios Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 8
  • Joined: 03-May 12


Posted 08 May 2012 - 06:36 AM

Mike how do i get your example files to open up with the BIRT version 3.6.1 i use. I got two Date parameters Start date and End Date and i want to uncheck "Is Required" field in the parameter. The purpose is either to get all the All dates or Data within the Date range and the onus is on the end user to determine what he prefers. I hope the info.. is suffice and it makes sense.
0

  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users