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)
How to use loop in Birt
abc123
<p>Hi Guys,</p>
<p> </p>
<p>I am making a birt report in spagoBi, I have the requirement</p>
<p> </p>
<p>I have query where a date parameter is used at several places. I have set two parameters for it startdate and enddate. i need that the query will execute for each date From startdate parameter to enddate parameter.(Loop). can somebody help me on this?</p>
<p> </p>
<p> </p>
Find more posts tagged with
Comments
pricher
<p>Hi,</p>
<p> </p>
<p>Can you be a bit more specific about the type of query you are using? Is it a SQL query? How do you set up your query parameters? Can you attach a report sample?</p>
<p> </p>
<p>For information, there is no concept of "looping" in a BIRT data set (query). It executes, then you get a result set (rows of data). That result set can be bound to a table to display the rows. This is where the "looping" happens.</p>
<p> </p>
<p>Regards,</p>
<p> </p>
<p>P.</p>
abc123
<p>Yes it is a sql query. I am using postgresql database. This is the query:</p>
<p> </p>
<p> </p>
<div>select count(distinct C.id) from </div>
<div>((select id from table1 where id_location = 4 and </div>
<div>and (((FromDate >= ? and Fromdate <= ?) and Fromdate >= ?) or </div>
<div>(Fromdate <= ? and (Todate <= ? and Todate >= ?)) or </div>
<div>(Fromdate <=? and Todate >= ?) or </div>
<div>(Fromdate >= ? and Todate <= ?))) </div>
<div>UNION </div>
<div>(select id from table2 where id_location = 4 and </div>
<div>Fromdate <= ? and Todate >= ?) ) as C</div>
<div> </div>
<div> </div>
<div>
<div> </div>
<div>In the parameter we put a date at all places(?) which starts from startdate and ends to enddate.</div>
<div> </div>
<div>We Set to parameters for it StartDate and EndDate</div>
</div>
pricher
<p>Hi,</p>
<p> </p>
<p>In your query, each question mark (?) is a placeholder for a <em><strong>query </strong></em>parameter. In your sample query, there are 12 question marks, hence 12 query parameters. However, since these query parameters are repeating themselves (FromDate and ToDate) , you actually need only 2 <em><strong>report </strong></em>parameters to run this query dynamically and provide a fromDate and toDate when the report executes.</p>
<p> </p>
<p>In the Data Set Builder, in the Parameters section, you can bind each <em><strong>query </strong></em>parameter to a <em><strong>report </strong></em>parameter, as shown in the screenshot below:</p>
<p>