j.seyfriedxiiix.de Posted January 11, 2020 Share Posted January 11, 2020 I've got a datasource where the data is stored in tables with language prefixes and I'd like to let the user select the language as a parameter. I tried to handover the language prefix as a parameter in the FROM part of my SQL query, but Jasper Report won't execute that. Are there any other ways? Here's what I tried so far:SELECT * FROM $P(language)If it would be possible to join the parameter with a fix string that would be even greater:SELECT * FROM $P(language) + '_article_view_full' Link to comment Share on other sites More sharing options...
luked Posted January 12, 2020 Share Posted January 12, 2020 Have you tried using the open and close brace {} so your parameter will be -SELECT * FROM $P{language} Link to comment Share on other sites More sharing options...
j.seyfriedxiiix.de Posted January 13, 2020 Author Share Posted January 13, 2020 Sorry, thats just a mistake in transcribing it here. I've tried it with $P{language} but instantly when adding this from the list of parameters it underlines this part red and explains when hovering over it "no viable alternative at input '$P{language}' " Link to comment Share on other sites More sharing options...
santhosh.devadurga Posted January 21, 2020 Share Posted January 21, 2020 I would suggest you to create a one more parameter like,Parameter Name: LanguageValueClass: StringExpression: $P{language} + "_article_view_full" ( better handle the null or empty value cases for $P{language} )Then query like, SELECT * FROM $P!{languageValue} ( ! should be there )Let me know if you have any concerns Link to comment Share on other sites More sharing options...
j.seyfriedxiiix.de Posted January 23, 2020 Author Share Posted January 23, 2020 Thanks Santhosh, I've tried it the way you suggested and I receive the following errors:net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:1. de cannot be resolved to a variable value = de; //$JR_EXPR_ID=0$ <>2. de cannot be resolved to a variable value = de; //$JR_EXPR_ID=0$ <>3. de cannot be resolved to a variable value = de; //$JR_EXPR_ID=0$ <>3 errors. at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:206) at net.sf.jasperreports.eclipse.builder.JasperReportCompiler.compileReport(JasperReportCompiler.java:286) at com.jaspersoft.studio.editor.preview.view.control.ReportController.compileJasperDesign(ReportController.java:478) at com.jaspersoft.studio.editor.preview.view.control.ReportController.access$8(ReportController.java:463) at com.jaspersoft.studio.editor.preview.view.control.ReportController$1.run(ReportController.java:381) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56)[/code] 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