adrianzazugmail.com Posted February 6, 2020 Share Posted February 6, 2020 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 tablewhere 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:0and 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. Link to comment Share on other sites More sharing options...
luked Posted February 7, 2020 Share Posted February 7, 2020 Give the below a try -Boolean.valueOf($p{}==1) ? 26 : 0So what the above will do if your parameter equals 1 then return 26 else 0 Link to comment Share on other sites More sharing options...
I am Leo Posted February 7, 2020 Share Posted February 7, 2020 You can not set the value of the parameter in the conditional (ternary) operator.Try the way that @luked comment. Link to comment Share on other sites More sharing options...
trvpseudo Posted February 7, 2020 Share Posted February 7, 2020 try to move the logic to sql Link to comment Share on other sites More sharing options...
trvpseudo Posted February 7, 2020 Share Posted February 7, 2020 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 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now