Hi, I created a report with ireport 5.6 , this is by compatibility with java 7 and DBF. I try to do the folow:
my query is:
Select *
from table
where field_in_table = $p{parameter_name}
I need the folow: $p{}==1?$p{}=26:$p{}=0
(IF(parmeter==1) true value parameter =26, false value parameter=0)
I tryed writed in default value expression of the parameter and there is a error, i writed:
$p{}==1?$p{}=26:$p{}=01?26:0 and not run the report,
too 1?26:0 run the report but no filter in the query sql.
I tryed with $p{}.intValue==1?26:0
and with $p{}.intValue==1?$p{}.intValue=26:$p{}.intValue=0 there is error.
How can I make the parameter change its value so that it is filtered by the expression WHERE of the query in sql.
Thank.
1 Answer:
u cant add logic in parameter default expression, coz default expression will be overwritten by the time user give an input.
try to add logic into ur SQL instead :
select *
from [table_name]
where [column_name] = (case when $P{param_name} = 1 then 26 else 0 end)
u can put the logic to variable. but i hvnt tried adding variable to the SQL.
regards, TV
Give the below a try -
Boolean.valueOf($p{}==1) ? 26 : 0
So what the above will do if your parameter equals 1 then return 26 else 0
You can not set the value of the parameter in the conditional (ternary) operator.
Try the way that @luked comment.
try to move the logic to sql