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)
Parameter in SQL Query - WHERE Clause
Miss_Anonymus
<p>Hello,</p>
<p> </p>
<p>I have the following problem:</p>
<p> </p>
<p>I would like to use a report parameter in my SQL Statement for my DataSet. It is called "FILTER" and a boolean type. I have the following DB table:</p>
<p> </p>
<p> </p>
<p><strong>ID Name Gender</strong></p>
<p>11 Lisa female</p>
<p>12 Max male</p>
<p>13 Linda female</p>
<p>14 Mary female</p>
<p> </p>
<p>When the FILTER parameter is given as true, only the female should be selected.</p>
<p>So:</p>
<p> </p>
<p>Select * from table where Gender = 'female'.</p>
<p> </p>
<p>When the FILTER paramter is given as false, the male should be selected. The query would be:</p>
<p> </p>
<p>Select * from table where Gender = 'male'.</p>
<p> </p>
<p> </p>
<p> </p>
<p>How can I do that in BIRT? With a single SQL Statement or with another tool? The additional misery is that I render the report into CSV and not PDF or something, so that ONLY the bindings get exported and not things that stand in texts or something. So I have to do that all in the declaring of the DataSet.</p>
<p> </p>
<p>Thanks already for your help!</p>
Find more posts tagged with
Comments
mwilliams
<p>In your data set, put the simple query:</p>
<p> </p>
<p></p><pre class="_prettyXprint _linenums:0">select * from table</pre>
<p> </p>
<p>In your data set's beforeOpen script (select data set in Data Explorer and then select script tab below design window) put something like this:</p>
<p> </p>
<p></p><pre class="_prettyXprint _linenums:0">if(params["myparam"]){
this.queryText = this.queryText + " where Gender = 'female'";
}
else{
this.queryText = this.queryText + " where Gender = 'male'";
}
</pre>
Miss_Anonymus
<p>Thank you very much !! Works fine.</p>
Kratika
<p>Hi Jason,</p>
<p> </p>
<p>i have 2 parameters, param 1 and Param 2 are drop downs. Param 2 depends on Param 1 selection. User may or may not select Param 2. How do i write dynamic query based on the param2 selection.</p>