JasperReports queryString questions
843785Jul 23 2008 — edited Sep 26 2008Hello,
I need to select some table in my query. The name of the table is given in java class that passes it to my .jrxml file to be used in my querystring.
I set parameters in javacode like this:
Map<String, String> inputParameters = new HashMap<String, String>();
...
inputParameters.put(jrxmlFieldName1,jrxmlParameter1);
inputParameters.put(jrxmlFieldName2,jrxmlParameter2);
jasperReport = JasperCompileManager.compileReport(getJRXMLName());
jasperPrint = JasperFillManager.fillReport(jasperReport,
inputParameters, connection);
I am trying to run the following query:
<parameter name="selFileVersion" class="java.lang.String" isForPrompting="true" >
<defaultValueExpression ><![CDATA["someFileVersion"]]></defaultValueExpression>
</parameter>
<parameter name="selId" class="java.lang.String" isForPrompting="true" >
<defaultValueExpression ><![CDATA["Id"]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[select * from $P{selFileVersion} where Id = $P{selId} ]]>
</queryString>
<field name="Id" class="java.lang.String"/>
That querystring doesnt work. What is wrong?
Also one of the parameters must allaw report to display all values in the field and when I use
<![CDATA[select * from someFileVersion where fieldName = "fieldName" ]]> it works and displays all the data but when I set parameter fieldName in java class it gives me empty report:
<![CDATA[select * from someFileVersion where fieldName = $P{fieldName} ]]> what is incorrect?
And one more question: why cant I use query like this:
<![CDATA[select * from someFileVersion, someApplicationVersion where someId = $P{selsomeId}, someName = $P{selsomeName ]]>
Thank you in advance for soon reply!