Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Running of Querries by using javascript / part 1
NewInBirt
Hi,<br />
<br />
i programmed a "Open Data Access" Driver. It will connected with a Java System.<br />
The java system is a product managment system, which consist products, orders, prices, etc...<br />
<br />
<strong class='bbc'>The actual situation:</strong><br />
<br />
1. I create a "data source" with the oda driver to the java system.<br />
<br />
And now we are comming to my problem:<br />
<br />
2. I create a "data set" and type the query inside.<br />
The product managment system don´t support sql, only a integrate unbeautiful database language.<br />
<br />
If i would like to get information of 2 tables (orders, products), I have to create 2 <strong class='bbc'>Data Sets</strong>:<br />
<strong class='bbc'>(A Data Set integrates a query)</strong><br />
<br />
Data Set1:<br />
select orders of OrderTable<br />
<br />
and my Data Set2:<br />
select products of ProductTable<br />
<br />
etc....<br />
<br />
For every query I have to create a new Data Set and therefore a new Query.<br />
<br />
That was only a easy example.<br />
<br />
In the praxis I have to create more than 10 Data Sets or more.<br />
(SQL isn´t possible to use)<br />
<br />
Is it possible to create with javascript, maybe in the beforeOpen, a script like that:<br />
<br />
var array = ["productTable", "orderTable", "priceTable"];<br />
var puffer;<br />
<br />
for (i=0;i<=10;i++)<br />
{<br />
puffer = select * from array<br />
//table.add(puffer)<br />
}<br />
<br />
<strong class='bbc'>Would you like to say me please, if that steps are possible with BIRT?</strong> <br />
I don´t know the exact code, it is only for demonstration.<br />
<br />
Thank you!<br />
<br />
Bye
Find more posts tagged with
Comments
JasonW
If you want to iterate over data you have to use a birt dataset. The dataset could be a scripted dataset where you call out to some java class that executes your query though.
NewInBirt
Hi JasonW,
thank you very much for your answer. It makes me happy to know that there is a possibility.
That point is exactly the topic, which i am looking for.
Do you have any hint for me, how to learn that? (Or maybe how can i find a tutorial, which treats this topic)
Best regards
Virgil Dodson
There are a couple of Scripted DataSet examples in the DevShare area of BIRT Exchange. Here is a direct link to one <a class='bbc_url' href='
http://www.birt-exchange.org/devshare/designing-birt-reports/544-sample-birt-scripted-data-source-example/#description'>Sample
BIRT Scripted Data Source Example - Designs & Code - BIRT Exchange</a>
NewInBirt
Hi,<br />
<br />
thank you very much for the link.<br />
The tutorials i have already viewed. But it helped me just a little for my problem.<br />
<br />
How is the correct procedure?<br />
<br />
I would do this steps:<br />
<br />
<strong class='bbc'>1.</strong> <br />
Go to the Birt Report Designer and create a new report.<br />
<br />
<strong class='bbc'>2.</strong><br />
Create a new Data Source with my Custom ODA Extension.<br />
<br />
<strong class='bbc'>3.</strong> <br />
Create a new Data Set by using the Data Source of Point 2,<br />
<strong class='bbc'>but how should be the query?</strong><br />
<br />
I would create a similar query to the query of the script "beforeOpen".<br />
query:<br />
select * from products.<br />
<br />
Is that query correct?<br />
<br />
<strong class='bbc'>4.</strong><br />
Create a new table with 5 columns by using the palette<br />
(push the table with 5 columns from the palette into the report)<br />
<br />
<strong class='bbc'>5.</strong><br />
Is it right to go to the <strong class='bbc'>Data Set Script</strong> beforeOpen ?<br />
Inside of that script I would declare an array and that loop:<br />
<br />
Script beforeOpen<br />
<br />
var arrayOfSomeTables = {"products", "orders", "prices", "customers", "vendors"}<br />
<br />
for (i=0;i<=10;i++)<br />
{<br />
this.queryText = "select * from " + arrayOfSomeTables
<br />
}<br />
<br />
But now i have 2 important questions, which i don´t know:<br />
<strong class='bbc'>- How can I call the query within of a loop step?</strong><br />
<strong class='bbc'>- How can I put the result of the query calls to the 5 cells of the table.</strong><br />
<br />
Sorry, for the much questions, but i am new to birt. I haven´t found a solution to that problem in the forum or with google search.<br />
<br />
Thank you a lot.<br />
<br />
Bye<br />
NewToBirt
NewInBirt
<blockquote class='ipsBlockquote' data-author="JasonW"><p>If you want to iterate over data you have to use a birt dataset. The dataset could be a scripted dataset where you call out to some java class that executes your query though.</p></blockquote>
<br />
Hi JasonW,<br />
<br />
it isn´t easy to understand everything of your suggestion.<br />
<br />
What do you mean with a "scripted dataset"? Is it, a certain data set, where i use a script? <br />
And which script i have to use by the way? (beforeOpen, beforeClose, onFetch, afterOpen, afterClose)<br />
<br />
And within of this script, I import the java-class and iterate with a loop<br />
above the calling of the query (the calling of the query is following through a java method ).<br />
<br />
Is it right?<br />
<br />
Hopefully you have a tipp for me.<br />
<br />
Best regards<br />
NewInBirt
JasonW
That is correct, except a scripted data set can be written in JavaScript or Java. So in the beforeOpen you could call like this:
1 - call and get first results in a map
2 - call and get second results in a map
Assuming both maps are the same size iterate over the maps and set the values for all the columns you have. The only problem is you have to know the number of columns you will have prior to building the script. You may want to look at modifying your ODA to support some sql like selecting from multiple tables.
Jason
NewInBirt
JasonW, thank you very much.
I could get it running. Without of your tip, i couldn´t never have done it.
I have just another problem, to put the results to a table. But i want to open a new thread.
Best greetings
NewInBirt