Home
Analytics
Setting dataset input parameters value
sabrosafb
Hi,
I'm new to BIRT reports so i'm playing around with the concept and trying to master the basics...
I've got a main data set fetching results, and for each result there is a list of sub tables that must be based on some key. I first designed a report parameters, and I would change it's value in the fetch() method of the main data set, thinking it's value would be updated at each row, and I could use the global parameter in the children data set to modify my WHERE clause.
I was wrong, or I was doing it the wrong way because in the end, the children sets would ALWAYS use the LAST key fetched from the main data set.
So I thought of using the child dataSet input parameters. I created new string parameter, and used it in the open() method to build a SQL statement.
My question is : I do I set this parameter value? I thought that from the fetch() method of the of the main data set I could somehow get the data set object and change it's parameter value, but I can't seem to find out why.
Maybe this this is REALLY simple and and that it's right in front of me but please help!
thanks
Frank
Find more posts tagged with
Comments
mwilliams
Hi Frank,
I'm not sure I'm understanding completely. Is there any way you can explain a little more? A sample report using the sample database that does what you're describing may help as well. What version of BIRT are you using?
sabrosafb
Hi mwilliams,<br />
<br />
Re-reading myself I find out i'm far from being as clear as I thought I was.<br />
<br />
OK I have 4 DataSets, from 1 to 4 let's say.<br />
<br />
The #1 is used to bring the master records, Work Orders, each having a Work Order #. For each row pulled out from the first DataSet I need to run 3 queries (data Set #2,#3,#4)<br />
<br />
I am defining the SQL query in the open() method of each dataSet. The way I was successfull was by, in the open() method of the 3 "child" dataSet, refer to the current top row to get it's data<br />
<br />
sqlText = "select matusetrans.refwo,pr.parent,itemnum,unitcost,linecost,transdate,quantity from matusetrans "<br />
+ "left outer join workorder pr on pr.wonum = matusetrans.refwo and pr.siteid=matusetrans.siteid "<br />
+ " where matusetrans.refwo = '" + <strong class='bbc'>rows[0]["wonum"]</strong> +"' or parent= '" +<strong class='bbc'> rows[0]["wonum"]</strong> +"'";<br />
;<br />
<br />
So that was a working solution that I took from an example somewhere.<br />
<br />
My first question was : what if I wanted to use a input parameters. I would have defined some "wonum" input param for the dataSet, and get its value using : inputParams["wonum"]<br />
<br />
But how would I set the input param value for each dataSet? Those are not Report wide parameters, and I need to set it once the row from the top level record is fetched.<br />
<br />
Hope this is clearer now. In anyway I have a solution but i'm trying to understand the concept here, and not only put some cable and wire to make it hold all together.<br />
<br />
Thanks<br />
<br />
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="65769" data-time="1277132012" data-date="21 June 2010 - 07:53 AM"><p>
Hi Frank,<br />
<br />
I'm not sure I'm understanding completely. Is there any way you can explain a little more? A sample report using the sample database that does what you're describing may help as well. What version of BIRT are you using?<br /></p></blockquote>
johnw
Your making that a whole lot more complicated than it needs to be. Basically your are just doing a Master/Detail report, you can define 4 data sets, each with their own parameters. So in your query, you'd have:
select matusetrans.refwo,pr.parent,itemnum,unitcost,linecost,transdate,quantity from matusetrans where refwo = ?;
The question mark will set up a parameter binding for your dataset. When you do to the Parameters section of your Data Set editor, you would set up the datatype, name, etc etc.
Then, you take your master data set, drag it over to your report to create a table. In the Detail row (or add a new detail row if you need to display all the data from that row), you drag the child dataset over into the detail row, which will create a table within the table. You select the child table, and under the Property Editor, you would select Bindings and click on the Parameter Binding button. You then click set an expression to your outter tables row["whateverParentId"].
You can find an example of how to do this if you for to your BIRT Window/Show View/Reporting (or BIRT, or Business Intelligence and Reporting, I don't remember off hand)/Report Examples. Under the Report Examples view, there should be a Report Designs/Master-Detail, or Parent Child report. this will show you how a finished report design would look. I believe there is also a tutorial in the Help file.
sabrosafb
Thanks,
See this is exactly what I was looking for. I thought I could get into it without having a little tutorial but I guess this is what I need.
Thanks a lot