kmarchewa Posted June 3, 2020 Share Posted June 3, 2020 Hello all.I am trying to resolve an issue with a Jasper report I am working on. This report uses an SQL query that returns a result of the form: (col_label VARCHAR, plu_nums varchar[], plu_names varchar[])[/code]To simplify working with these Array values, I have created two variables in Jaspersoft Studio: <variable name="pluLength" class="java.lang.Integer"> <variableExpression><![CDATA[$V{pluArray}.length]]></variableExpression> <initialValueExpression><![CDATA[0]]></initialValueExpression> </variable> <variable name="pluArray" class="java.lang.String[]"> <variableExpression><![CDATA[((String[]) ($F{plu_names}.getArray()))]]></variableExpression> </variable>[/code]My detail band is defined (in part) as: <reportElement x="0" y="0" width="50" height="18" uuid="3a44195d-3306-421e-b898-11350bcca596"/> <textFieldExpression><![CDATA[$V{REPORT_COUNT} == 1 ? "Prop " +$F{plu_names}.getArray() : $V{pluLength} ]]></textFieldExpression> </textField> <textField> <reportElement x="50" y="0" width="50" height="18" uuid="53b9e1cc-2726-4f48-93fc-09f5cdaf597f"/> <textFieldExpression><![CDATA[$V{pluLength} >= 1 ? $V{pluArray}[0] : ""]]></textFieldExpression> </textField> <textField> <reportElement x="100" y="0" width="50" height="18" uuid="dfb393eb-4f75-47d3-a1cc-a90bdc954105"/> <textFieldExpression><![CDATA[$V{pluLength} >= 2 ? $V{pluArray}[1] : ""]]></textFieldExpression> </textField> <textField> <reportElement x="150" y="0" width="50" height="18" uuid="86a485d1-f7ee-4aab-bde9-8c6738349f23"/> <textFieldExpression><![CDATA[$V{pluLength} >= 3 ? $V{pluArray}[2] : ""]]></textFieldExpression> </textField>[/code]It works as expected, except for the first row. The array I am attempting to access is null. I had assumed it might have something to with the variable definition/time of evaluation, so tried using definition of "pluArray" (e.g. the casting of "plu_names" field as a String[]), in place of variable itself, but the result was the same. The "col_label" field is populated correctly in the first row, but not "plu_names" Array variable. To clarify, the field is not null in the SQL result itself. I even changed to order to verify this. When the sort order was change, the record that had a null value for the "plu_names" field was now populated (since it was no longer the first row) , and the "plu_names" field in the "new" first row (with the updated sort order) was null even though it had previously been populated. The issue is not with any particular record from the DB, but always the first row in the report.Any advice would be appreciated. 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