Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
building dataset based on another dataset
gib65
<p>Hello,</p><p> </p><p>I have a dataset. I now want to build another dataset based on the first dataset (as if the first dataset was a data source). Is this possible? Can it be done in scripting? If so, what would the script look like?</p><p> </p><p>If this is not possible, maybe I can do this in a single dataset with a more complex query. The query I currently have for the first dataset is as follows:</p><p> </p><p>{call MyStoredProcedure(?,?)} <-- where the first ? is an input parameter and the second ? is an output parameter (SYS_REFCURSOR in the stored procedure).</p><p> </p><p>What would a simple select statement look like if it drew from the results of this stored procedure call?</p><p> </p><p>Thanks for all forthcoming help.</p>
Find more posts tagged with
Comments
mwilliams
<p>You can build another dataset based on another. You simply would need to store the values from the first dataset into arrays or whatever you choose and then use these arrays to create a scripted dataset. You can either use the data engine API to access the dataset from the beforeFactory or you could hide a text box bound to your original dataset at the top of your report and just access the data in the onFetch of the dataset.</p><p> </p><p>Hope this helps. Let me know if you need a better explanation.</p>
gib65
<p>Thanks a lot, mwilliams,</p><p> </p><p>I don't think I need a better explanation for now. It sounds like I should follow some tutorials on scripting in Eclipse/BIRT. Once I figure out the basics of scripting, I'll see if I can tackle datasets. At that point I may come back with further questions.</p><p> </p><p>Thanks again.</p>
mwilliams
<p>Okay. If you tell me your BIRT version, I could provide a simple example.</p>
gib65
<p>Seems to be 4.3.0.</p>
mwilliams
<p>Okay. Just give me a few minutes and I'll take the data from one dataset and transform it into a new result set in a scripted dataset. I'll do something real simple, but it'll give you an idea of what needs to be done.
</p>
mwilliams
<p>Take a look at this report. The text at the top is bound to the original dataset. This forces that dataset to run. The script in the original dataset (beforeOpen, onFetch, and beforeClose) creates and fills an array and then stores that to a PGV for use in the scripted dataset.</p><p> </p><p>In the scripted dataset (open and fetch) the PGV is retrieved and the results are stepped through and grouped. Finally the now grouped values are written to rows in this result set and displayed in the report.</p>
gib65
<p>Thanks mwilliams, I'll have a look at that.</p>
gib65
<p>Hi mwilliams,</p><p> </p><p>I'm playing around with the scripts you gave me. I think I understand how they work.</p><p> </p><p>One question I have for you is: how did you get the additional event handlers in Data Set1 (like open, describe, fetch, and close)? Accord to this website: <a data-ipb='nomediaparse' href='
http://www.eclipse.org/birt/phoenix/deploy/reportScripting.php'>http://www.eclipse.org/birt/phoenix/deploy/reportScripting.php</a>
, the only events available to datasets are beforeOpen, afterOpen, onFetch, beforeClose, and afterClose.</p>
mwilliams
<p>Those are only for the scripted dataset.</p>
gib65
<p>I don't understand. What makes a dataset "scripted"? Do you mean you created it in the script? If so, I didn't see where. Other than that, Eclipse/BIRT seems to give 2 options: create a SQL Select Query dataset or a SQL Stored Procedure Query dataset, neither of which have those events listed in the script dropdown.</p><p> </p><p>Thanks for your patient mwilliams.</p>
mwilliams
<p>To have a scripted dataset, you need to have a scripted datasource. If you look at the report I made, there are two datasources. One connects to the sample database, the other is just a datasource to be used by the scripted dataset. If you go to your data explorer and create a new data source and choose the scripted type, then create a new dataset, you'll see the other script methods.</p>
gib65
<p>Thanks Michael,</p><p> </p><p>I managed to create a scripted dataset, fill it with data, and use it to populate a table. Works beautifully.</p>
mwilliams
<p>Awesome! Great to hear!
</p>