Jump to content
Changes to the Jaspersoft community edition download ×

Simple table lookup using existing datasource


natfire

Recommended Posts

Forgive my ignorance - I'm a newbie to iReports!

Is it possible to perform some sort of simple table lookup using the existing database connection for data that is not available from the Report Query?

For example - looking up standard header & footer text?

I can use a subreport, but this seems to be overkill for a simple function.

 

Some sort of formula in the expression editor would appear to be the obvious solution - is that possible?

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

No it's not possible to do a simple table lookup. One of the drawbacks to Jasper Reports is the query restriction. You can create sub queries but they can only be used in charts and cross tabs.

 

If you want to create queries to get data outside of you main query there are several things you can do.

 

1. Create a subselect in your main query that get the data that you require.

 

2. Use a subreport

 

3. Create the SQL logic in Java in a scriplet to get the data you require.

Link to comment
Share on other sites

Thanks for the prompt response Svenn - much appreciated!

Your answer confirmed what I was expecting.

 

If the choice is between a sub report and a Java scriptlet - which whould be most efficient in a a run-time/production environment?

 

The particular problem I'm trying to solve, is standard hearder and footer data that is stored in a database table. All reports would be using the same header and footer layout. If the lookup data was in a sub-report that was being reused, would this be 'cached' by the report server?

 

Thanks again for your help.

Link to comment
Share on other sites

No it would not be cached so you would have to make a database call every time you created a header.

 

Out of my three options number one would be your best bet as you could include the information as part of your main query.

 

Another approach you might want to look at is retrieving you header and footer data outside of the report and passing the values to the report with parameters.

 

All of our report are Multilanguage so we retrieve all the language string for our headers and footer in our Java business logic then we and pass this information to the report.

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...