Welcome Guys...!!!
Today v'll learn most important first 2 types of parameters out of 3.
1) $P{Parameter_Name}
2) $P!{Parameter_Name}
3) $X{.......}
Third type of Parameter is briefly explained in my next post for more deeper understanding.
Step 1 : Create a executable report with a query where there are no parameters at first.
In current example I will be using "select * from address".
Step 2 : Assuming filter on Field "City", here we will use following code in query.
Step 3 : Finally 1st type of Parameter $P{...} returns desired output as shown in below screenshot.
Step 4 : We will create 2nd type of parameter within same query as shown below :
Step 5 : Result of 2nd type of Parameter is shown below as First Filter was on Field city = "Dallas" and Second Filter on Field lastname = "Steel".
That's it.
Hope you enjoyed this post.
For more queries please contact me on: miwagada@gmail.com.
Today v'll learn most important first 2 types of parameters out of 3.
1) $P{Parameter_Name}
2) $P!{Parameter_Name}
3) $X{.......}
Third type of Parameter is briefly explained in my next post for more deeper understanding.
Step 1 : Create a executable report with a query where there are no parameters at first.
In current example I will be using "select * from address".
Step 2 : Assuming filter on Field "City", here we will use following code in query.
"select * from address where city=$P{city_name}"
$P{city_name} is a newly created parameter with properties set as shown in below screenshot.
Check or uncheck "Is for Prompting" property as value mentioned in "Default Value Expression" is set to "Dallas". Hence ResultSet will only return records with city which matches value as Dallas.
Check or uncheck "Is for Prompting" property as value mentioned in "Default Value Expression" is set to "Dallas". Hence ResultSet will only return records with city which matches value as Dallas.
Step 3 : Finally 1st type of Parameter $P{...} returns desired output as shown in below screenshot.
Step 4 : We will create 2nd type of parameter within same query as shown below :
"select * from address where city=$P{city_name} and $P!{extended_query}"
Here $P!{...} contains SQL query (whether a query as a whole [select statement or partial one] by replacing SQL query to Parameter syntax in "Dataset and Query Dialog" as shown in below screenshot.
In current scenario, we have used below sql as a partial one :
"lastname ="+"'Steel'"
If the Field "lastname" is of String Class, we have to enclose the assignment value in Single quotes
(' ') within double quotes else the value itself in double quotes. Please refer below screenshot of Parameter creation and its properties.
Step 5 : Result of 2nd type of Parameter is shown below as First Filter was on Field city = "Dallas" and Second Filter on Field lastname = "Steel".
That's it.
Hope you enjoyed this post.
For more queries please contact me on: miwagada@gmail.com.
Comments
Post a Comment