Jump to content
Changes to the Jaspersoft community edition download ×

Subreports: error preparing statement for executing the report query


iswanlund
Go to solution Solved by iswanlund,

Recommended Posts

Hello,

I am building a report with a subreport, but keep getting the same error.

Pertinent report code:

    <queryString>
        <![CDATA[select
        pofr.id as pofrid,
        from product_orders_for_reports pofr
        where pofr.id = 1773589]]>
    </queryString>
    <field name="pofrid" class="java.lang.Integer"/>
    <detail>
        <band height="671" splitType="Stretch">
            <subreport>
                <reportElement x="40" y="450" width="200" height="200" uuid="04e3d2b5-27e3-4cf8-921c-7471b7bda468"/>
                <subreportParameter name="POFR_ID">
                    <subreportParameterExpression><![CDATA[1773589]]></subreportParameterExpression>
                </subreportParameter>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA["consumer_subreport.jasper"]]></subreportExpression>
            </subreport>
        </band>
    </detail>

Pertinent subreport code:

    <parameter name="POFR_ID" class="java.lang.Integer">
        <defaultValueExpression><![CDATA["1773589"]]></defaultValueExpression>
    </parameter>
    <queryString language="SQL">
        <![CDATA[select pofr.id
        from
        where pofr.id = $P{POFR_ID}]]>
    </queryString>

 

And the error text:

......JRException: Error preparing statement for executing the report query:

select

....

where pofr.id = '?'

.......Caused by: .... The column index is out of range: 1, number of columns: 0.

 

Does anyone have an idea why this is happening, and what I can do to fix it?

Thanks!

EDIT: Also, the subreport runs perfectly fine on its own if the pofr.id is hardcoded, and the report runs fine when no subreport is hooked up. The subreport parameter POFR_ID should take the field variable pofrid from the main report, but I get the same error no matter what is passed into it.

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hi sanbez, thank you for taking the time to look at this!

Actually, in my zeal to delete unnecessary code I removed an inner join

inner join product_orders_for_reports pofr

 

Also, when I remove the subreportParameterExpression and try to run the main report with the subreport hardcoded, I get a String Integer error. The main report sans subreport, and the subreport solo, run perfectly. Are these errors related?

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...