I've been executing this in iReport. I am trying to get it to work there before uploading it into JasperServer. According to iReport the syntax you specified isn't valid. So when I upload it to the JasperServer. It won't even execute. I normally get it working in iReport before uploading it in JasperServer... What does the $$ do? Is there any documentation on it? BTW. I am using iReport 3.1.2 and JasperReports 3.1 I've tried $P{Country_ISO3166} == null ? "IS NULL" : "= "+ $$P{Country_ISO3166} As the expression used in the derivied parameter. iReport indicates that the $$ is a syntax error. And the query is... select IndexName from `Indices` where Country_ISO3166 $P{Country_ISO3166WhereClause} There will be single quotes around the entire where clause. I turned on the SQLException log and the query looks like this select Industry, Publisher, IndexName from `worldindices` where Country_ISO3166 '= AR' when the query is changed to When I change the query to use $P!{Country_ISO3166WhereClause} the query turns into ... select Industry, Publisher, IndexName from `worldindices` where Country_ISO3166 = US then query engine thinks the value is a column so I had to change the expression to surround the value with quotes. $P{Country_ISO3166} == null ? "IS NULL" : "= '"+ $P{Country_ISO3166}+"'" This changes the query to select Industry, Publisher, IndexName from `worldindices` where Country_ISO3166 = 'AR' exactly what I want.... But it returns no values...... I execute the same query in an external SQL Client and it works. However I did find this in the logs Tue Feb 03 12:35:27 EST 2009 INFO: Profiler Event: [sLOW QUERY] at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createDatasource(JRJdbcQueryExecuter.java:135) duration: 1 ms, connection-id: 120, statement-id: 16, resultset-id: 16, message: The following query was executed with a bad index, use 'EXPLAIN' for more details: select Industry, Publisher, IndexName from `worldindices` where Country_ISO3166 = 'AR' and when I COPY and PASTED the complete SQL statement into my SQL client I get this Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select Industry, Publisher, IndexName from `worldindices` where Country_' at line 1 SQLState: 42000 ErrorCode: 1064 It appears like a bunch of extra characters have been inserted into the query somehow. The actually SQL looked fine. ONly when I executed it, I received this message. I actually manually deleted the bogus characters by delete and re-inserting the whitespace. Any ideas???????? I think the reporting engine is somehow inserting those bad chars. Post Edited by Cory Hubert at 02/03/09 17:51 Post Edited by Cory Hubert at 02/03/09 17:53