Using One DataSet To Filter Another DataSet or Table?
<p>Hello,</p>
<p> </p>
<p> I'm a neophyte in the BIRT world, and I was wondering if I could get some input on a technique...</p>
<p> </p>
<p> Recently, due to a software upgrade, a particular application that I develop for and administer began having problems with particular Crystal based reports that we have been using for a couple years. This problem has been identified as a bug, and will be addressed in a future update. In the meantime, though, I was sort of left hanging. This application supports two reporting engines: Crystal and BIRT, with BIRT being the preferred solution for future development. Therefore, I decided to tackle the job of rewriting these reports in BIRT.</p>
<p> </p>
<p> Luckily, I'm familiar with Eclipse in general, JavaScript and Java. It took two days, but I was able to rebuild this report in BIRT. It's one of our more complex ones, in that it has fifteen separate datasets. The layout however is fairly basic. Once I got the hang of creating datasets, and passing parameters for use in the WHERE clauses, the rest of the process fell in line quickly. I was also able to increase the performance of this report from about ten minutes to under one minute, by refactoring the SQL queries. All in all, this might have been a blessing in disguise.</p>
<p> </p>
<p> There's two flavors of this report. The first accepts a record ID via a report parameter, which is passed in by the application. It prompts the user for two other parameters, a start date and end date used as parameters in most of the datasets as part of the WHERE clause. This version works great.</p>
<p> </p>
<p> The second flavor accepts a record ID via a report parameter, and then in the first dataset (bound to the first display table in the report, to guarantee execution order), it retrieves two datetime values, one from a table column, and the other being SYSDATE. The goal is to use these two values as filters in the remaining datasets, to restrict displayed data to a particular time range.</p>
<p> </p>
<p> I tried adding code to the onFetch event for the first dataset, and then set a persistent global variable to the value of the start date and sysdate fields returned by the dataset. Then, I added code to the onPrepare events for each of the display tables, and dynamically added filters to the tables at runtime based on these two persistent global variables. I thought this would work, but after playing with this idea, I cannot seem to get it to. The tables keep returning no records when I dynamically filter them based on the two variables. Although, I know the filtering code is working, because I can hard code the variables to specific values, and the filtering works. So, the problem seems to be related to retrieving the values from the first dataset, and setting the global variables.</p>
<p> </p>
<p> I can think of two ways to handle this:</p>
<p> </p>
<p> 1) Filter the data at the presentation layer level, which is what I attempted to do. If you say that this is a reasonable method, I will continue to pursue this course, and will try to figure out what the issue is.</p>
<p> </p>
<p> 2) Filter the data at the dataset level, which is what I'd prefer, since it would probably be more efficient due to returning less data to be further processed. I cannot quite figure out how to do this, though.</p>
<p> </p>
<p> I'll keep plugging away at this, and hopefully I'll figure it out... But, I'd really like some input from people 'in the know' to see which of these ideas is actually workable, or if neither is a good idea, how this should be handled. If anyone knows of an example report demonstrating such concepts, I'd love to see it.</p>
<p> </p>
<p> I guess if I generalize my question, it would go like this: "How can one take a value returned by one dataset, and use this to filter other datasets or tables?"</p>
<p> </p>
<p> Thanks in advance for any advice, pointers, or suggestions.</p>
<p> </p>
<p>Brad</p>
<p> </p>