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)
BIRT Multi-Select Statements an Multi parameter passing
Eswar B
Hi everyone,
How to send multiple parameters at a time from the front end to the report where the report should display the contents particular to those content send from those parameters.
select * from customers where city in (?)
form the above query in place of "?" I have to pass multiple parameters separated by comma from the front end.
The output report should give the results according to the parameters passed.
Please help me..if any one know how to do this.
Thanks in advance...
Find more posts tagged with
Comments
mwilliams
Take a look at this devShare post:
http://www.birt-exchange.org/org/devshare/designing-birt-reports/688-using-a-multivalue-parameter-in-an-in-clause/
Eswar B
Thanks Michael,
Its working fine but it is displaying the list of parameters from the birt parameter view.
what I need is
In my jsp page I have an text box inserted in <Birt:parameterPage> Tags
<input type=text name="id" value="submit ID">
Here the name of the text box is same as the report parameter what it should do is whatever the value I pass from the text box for example (11,12,13...) in the textbox saperated by comma should send to the report query as multiparameter list in the "select * from customers" and i have to add a "where id IN(11,12,...values from the text box should come here)" and retrieve the birt report.
please help me...........
hcy1986
You can modify the query in the beforeOpen event of the data set.<br />
with code similar to the following:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>/*
*Dynamic modify the sql before open the data set
*/
var macParmList = new Array();
var lpParmList = new Array();
//Get the input param,this param is an array.
macParmList = params["RP_macLpar"].value;
lpParmList = params["RP_lpar"].value;
var macInClauseStr = "";
var lpInClauseStr = "";
var isMacAll = false;
var isLpAll = false;
for(var i = 0;i<macParmList.length;i++){
if(macParmList[i]=='NO SELECT'){
macInClauseStr = "'-1',";
break
}else if(macParmList[i]=='ALL'){
isMacAll = true;
break;
}
else{
macLpList = macParmList[i].split(',');
for(var j=0;j<macLpList.length;j++){
macInClauseStr = macInClauseStr+("'"+macLpList[j]+"'"+",");
}
}
}
for(var i = 0;i<lpParmList.length;i++){
if(lpParmList[i]=='NO SELECT'){
lpInClauseStr = "'-1',";
break;
}
if(lpParmList[i]=='ALL'){
isLpAll = true;
break;
}else{
lpInClauseStr = lpInClauseStr+("'"+lpParmList[i]+"'"+",");
}
}
//Delete the ',' in the maked up lpInClauseStr.
var inClause = macInClauseStr+lpInClauseStr.substr(0,lpInClauseStr.length-1);
//If not select 'ALL' then the query sql is modified.The default query sql is select all.
if(!isMacAll&&!isLpAll){
this.queryText = this.queryText+" where L.BC_LPARNEWS_PNAME in ("+inClause+")";
}</pre>
Eswar B
Hi Hcy1986,
Thanks for your quick reply..
I am getting the error report parameter not set
I have only one parameter and it is being passed from the text box from the jsp page.
so I want the multiple values from the textbox to be taken as parametervalue.
please help me with that...
hcy1986
The parameter is from multiple select on the above code,so it is an array type.If the parameter type is string,it can be in the query like this:
"select * from table where in ('"+params["paramName"].value.replace(/,/g,"','")+ "')"
Eswar B
Thanks.....
I have tried it in different way and I got it right...
In birt report create a report parameter with type string and text box and check the box is required if you want...
then from the jsp page the name of the text box and the name of reportparameter should be same...
then in the beforeOpen write query.."this.queryText="select * from customers where id in ("+params["paramName"].value+")";
then if you enter id's in jsp text box it will filter the report using the id.....
hcy1986