Subreport problems

0
By: Jeff Sarret - chillifier
Subreport problems
2004-05-12 09:47
When I try to create a sub report exactly like the online tutorial shows, I get the following error when trying to update the detail SQL statement
select distinct state from cities where country = ${COUNTRY}

error is as follows
SQL problems:ERROR: parser:parse error at or near "$"

why do I get this error ?
I was able to create subreports in version -0.2.0




By: Rick Millar - rmillar
RE: Subreport problems
2004-05-12 11:19
Try the following instead:

select distinct state
from cities
where country = $P!{COUNTRY}

This should work assuming you have COUNTRY defined as a parameter in your report.




By: Jeff Sarret - chillifier
RE: Subreport problems
2004-05-12 12:08
Did that and now I get this error
Please set a default value for the paramater 'COUNTRY'




By: C-Box - c-box
RE: Subreport problems
2004-05-13 00:27
You have to declare the Parameter to the report's parameterlist first before you can use a parameter in any expression.....

I guess you want to put the Country from MasterReport towards SubReport, right? Then you need to declare the parameter in masterreports SubReport-Section:
<subreportParameter name="TestFeld">
<subreportParameterExpression><![CDATA[${COUNTRY}]]></subreportParameterExpression>
</subreportParameter>


and into your subreports-headersection you will need to declare the parameter again:

<parameter name="COUNTRY" isForPrompting="true" class="java.lang.String"/>

then you can use it into your query like that:

<queryString><![CDATA[Select state from cities where country = $P!{Country}]]></queryString>


hth
C-Box




By: C-Box - c-box
RE: Subreport problems
2004-05-13 00:29
ohh forgot the "F" in SubReportParameterExpression:

it should be:
<subreportParameterExpression><![CDATA[$F{COUNTRY}]]></subreportParameterExpression>

C-Box




By: Jeff Sarret - chillifier
RE: Subreport problems
2004-05-13 07:09
Thanks c-box,
I got it to work but the I had to edit the sub report query via a text editor and not through iReport because it kept giving me the error:

Please set a default value for the paramater 'COUNTRY'

and would not save the right query to the xml. I noticed this
every since the report query dialog has been updated to automatically read and register fields to the report.




By: Giulio Toffoli - gt78
RE: Subreport problems
2004-05-13 07:12
you can set a default value for the parameter in the subreport and it will never throw this error.

Giulio




By: Jeff Sarret - chillifier
RE: Subreport problems
2004-05-13 07:56
gt,
I created 2 forms now with integers instead of strings and can still get it to work only through editing the sub report query via an external editor.
If I try to add a default value for the paramater in the subreport like you suggested I get errors no matter what I try. I have tried the following as the default value
0 or 1
$P{NAMEOFTHEPARAM}
$F{NAMEOFTHEFIELD}
and cannot edit the query of the subreport without errors Thanks for all your replies




By: Giulio Toffoli - gt78
RE: Subreport problems
2004-05-13 15:24
try this:

new Integer(0)

Giulio




By: Jeff Sarret - chillifier
RE: Subreport problems
2004-05-13 15:36
Thats IT !!!!
Everything works like a charm :)

Thanks to everyone involved.
Thatks for a great program.

Jeff
2004 IR Help's picture
Joined: Aug 17 2006 - 3:49am
Last seen: 13 years 6 days ago

0 Answers:

No answers yet
Feedback
randomness