Jump to content

mapping db fields


dsaral

Recommended Posts

Hi,

 

I wondered if it is possible to map db fields? If a column name changes in db, do i have to modify all my field names in report, and also in scriptlets, isn't there any solution for this problem? To create parameters having expression of field values, and if any column name changes in db to change only parameter's expression is a way, but i wondered if there is any other specific solution?

 

Thanks for help

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

I've got a similar problem. When I try to View the report I fill, I get next error:

 

net.sf.jasperreports.engine.JRException: Unknown column name : ne

 

ne is the name of the employee in the select below:

 

select name as ne,surname,idemployee from employees where age>25;

 

 

Any ideas about how to solve it anyone?

 

Thnaks in advance.

 

Fran

Post edited by: indo2k, at: 2006/09/04 11:45

Link to comment
Share on other sites

If your column names could change, you should may be implement you own data source and add a flexible mapping of fixed field names to variable column names.

 

But, i did not really understand why column names are a subject to change. As long as your data model isn't stable, it isn't a good idea to start with a report implementation.

Link to comment
Share on other sites

Just because you can , does not mean you should.

Seriously you should not be changing your column names.

It shows that you have not sat down and thought enough about the data & format of your tables.

 

Yes you can code round it , by writing 'clever' datasource drivers, but ultimatly you cannot cleanly map the fields on your report to the database cols.

 

and god help you if your col order in the database is changed, if you do write such a driver.

 

 

Consider each time you change col name, you take the risk of introducing bugs & problems into your code base, and for nearly 20 years oracle would not allow you to change col names, only recently allowing the evil practice, because people were hacking the data dictionary, which was far more dangerous.

 

just think each time you do that change , you have to run all code & reports to verify you have not broken anything.

 

Sit back and mull it over for a while, and clearly think out your table structure.

Link to comment
Share on other sites

  • 2 weeks later...

I've got a similar problem, and I had to use connectorJ 5.0.3 for mysql.

 

I solved the problem use mysql function "cancat()", like this:

select concat(name, '') as ne, surname, idemployee from employees where age>25;

 

Good luck.

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