How to pass Multi and Singlr value Parameters to DB2 query, which is using in SSRS report
Hi Guys,
I am using DB2 database in SSRS. I have to pass Single Value and Multi Value Parameters. I tried with Select * From DB2Table Where
Column=@PRM_Name Or Select * From DB2Table Where
Column=:PRM_Name . It is not working and throwing error. Please help me out.
Connection Details: ODBC
Thanks Shiven:)
May 16th, 2011 3:25am
I would recomment you to construct the SQL query using the code as below using expressions.
="SELECT customer_name, telephone_number, address1, address2, city from MyTable WHERE city IN '" + Join(Parameters!City.Value,"', '") + "'"
Note : You can build a custom code also to construct the SQL statement by passing the parameters.
Free Windows Admin Tool Kit Click here and download it now
May 16th, 2011 3:45am
Hi SKM,
So you mean to say that Go to DataSource->Add Dataset-> Query Type-Text-> Under Query: click on fx (Expression)-> Write this expression
For Single Value Parameter:
="SELECT customer_name, telephone_number, address1, address2, city from MyTable WHERE city IN '" + Parameters!City.Value + "'"
OR
="SELECT customer_name, telephone_number, address1, address2, city from MyTable WHERE city IN '" & Parameters!City.Value & "'"
Keep it in mind If Parameter is String then It should be in Single quote ''.
Like
="SELECT customer_name, telephone_number, address1, address2, city from MyTable WHERE city ='Hyderabad' "
For Multivalu Parameter:
="SELECT EmployeeID, FirstName, LastName, LoginID FROM SHIVEN.AUDIT Where FirstName in
('" + Join(Parameters!PRM_Dwh.Value,"','") +
"')"
Thanks It is working fine but it is tough job if query is big.
May 16th, 2011 4:52am
Hi SKM,
So you mean to say that Go to DataSource->Add Dataset-> Query Type-Text-> Under Query: click on fx (Expression)-> Write this expression
For Single Value Parameter:
="SELECT customer_name, telephone_number, address1, address2, city from MyTable WHERE city IN '" + Parameters!City.Value + "'"
OR
="SELECT customer_name, telephone_number, address1, address2, city from MyTable WHERE city IN '" & Parameters!City.Value & "'"
Keep it in mind If Parameter is String then It should be in Single quote ''.
Like
="SELECT customer_name, telephone_number, address1, address2, city from MyTable WHERE city ='Hyderabad' "
For Multivalu Parameter:
="SELECT EmployeeID, FirstName, LastName, LoginID FROM SHIVEN.AUDIT Where FirstName in ('"
+ Join(Parameters!PRM_Dwh.Value,"','") +
"')"
Note: You have to write expression in one line in Expression editor for dataset query
Thanks It is working fine but it is tough job if query is big.
Free Windows Admin Tool Kit Click here and download it now
May 16th, 2011 4:52am