psundaravaradhan Posted February 8, 2016 Share Posted February 8, 2016 Am trying to limit the total rows to be printed in a report as a user defined function. select top $P{rowlimit} is something I can do in mssql. But this report could take any orcle datasource also. So is there a way to do this jasper level ? I read about report_max_count. But am not able to assign a value to this parameter.Can you please suggest a way to achieve this in jrxml? I can't use report scriptlet or java code. Link to comment Share on other sites More sharing options...
kkriplani Posted February 8, 2016 Share Posted February 8, 2016 You can use a page break and give it a print when condition like;$V{REPORT_COUNT} % 10 == 0Hope this helps,KKriplani Link to comment Share on other sites More sharing options...
christopher.g.kennedy Posted February 8, 2016 Share Posted February 8, 2016 At the oracle plsql level you can set rownum <= x in the where clause in your jrxml file. The following will return 5 itemnames from an item table when the user enters rowlimit = 5: <queryString> <![CDATA[selectitemname from items where rownum <= $P{rowlimit};]]></queryString>Hope this helps, Chris Kennedy Link to comment Share on other sites More sharing options...
hozawa Posted February 8, 2016 Share Posted February 8, 2016 There's isn't a property to set maximize row to fetch at JasperReports level. You'll need to have different datasources for mysql and oracle. Link to comment Share on other sites More sharing options...
psundaravaradhan Posted February 9, 2016 Author Share Posted February 9, 2016 I seem to have found a way to achieve this effect.<filterExpression> <![CDATA[$V{REPORT_COUNT}<=$P{rowlimit}]]> </filterExpression>[/code]$P{rowlimit} is the user defined parameter that can prompt. But not sure of the sideeffects, as in don't know if it actually fetches the top rows of select. Link to comment Share on other sites More sharing options...
zh3ntil Posted February 9, 2016 Share Posted February 9, 2016 Hi psundaravaradhan,You are right. That's the only way to make it on Jasper level is giving a filter expression. But If you want to use like that and the result set has too many rows, some performance issue will come with it. Because when you giving a filter expression for the top records, reports show top records after fetching all the query results. Link to comment Share on other sites More sharing options...
psundaravaradhan Posted February 9, 2016 Author Share Posted February 9, 2016 So are you saying the best way to get the top X rows is to alter the SQL query ? Link to comment Share on other sites More sharing options...
zh3ntil Posted February 9, 2016 Share Posted February 9, 2016 If your query result has too many rows, then yes.You should test two way and decide. In my experience, around 100K records the performance difference is noticeable. Link to comment Share on other sites More sharing options...
christopher.g.kennedy Posted February 17, 2016 Share Posted February 17, 2016 order by clause will return the rows you want in your limitted subset query, or additional where clauses. It may be data dependent. 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