Reputation: 19
I am beginner in Jasper report, i have created a jasper report table which contains more than one million data. I want to display the jasper report as per the user need.I have database in PostgreSQL named "Banke" and table named Arsenic_Test.i want to make a choice for my user to select the data, For example I have 3 options for the user to select "data with value X<50, X=50 or X>50. How to do this?
Upvotes: 0
Views: 623
Reputation: 1971
You need to use parameters in your queries. For example your query can look like
SELECT * FROM some_table WHERE X < $P{value_lower}
Ofcourse you have to prepare more complicated query. I think you need a 3 parameters - one for <
, another for =
and the last for >
and check them if they are not nulls in where cluase (because you can't provide an operation with parameter but just only the value). For example you can use something like this
SELECT *
FROM some_table
WHERE ($P{value_lower} is not null and X < $P{value_lower})
OR ($P{value_equal} is not null and X = $P{value_equal})
OR ($P{value_higher} is not null and X > $P{value_higher})
If you need more information about using parameters then look at for example this tutorial or if you want to learn more about connect JR with your site then you should look at http://community.jaspersoft.com/wiki/php-client-sample-code (specially at Reporting Services section). For example if you want know how to provide inputs then you should look at this example
$controls = array(
'Country_multi_select' => array('USA', 'Mexico'),
'Cascading_state_multi_select' => array('CA', 'OR')
);
$report = $c->reportService()->runReport('/reports/samples/Cascading_multi_select_report', 'html', null, null, $controls);
echo $report;
Upvotes: 1