Jump to content
JasperReports Library 7.0 is now available ×

Need help and I'm in a big hurry


2005 IR Help

Recommended Posts

By: Augustin Boteanu - aboteanu

Need help and I'm in a big hurry

2005-06-30 13:11

Hi, i have just started to use iReport and JasperReports yesterday si i can save development time for an app i'm working on, so you can say i'm a total beginner.

 

I use HSQLDB as a database, and it works fine with simple reports.

 

My problems:

 

SHORT VERSION:

1) How do i use column aliases in queryes - it gives me errors about not finding that column (select tbl.col as my_column - sais 'Unknown column name: my_column')

 

2) i have in the detail of a group on each row a variable witch is calculated by multiplying 2 fields. i want at the end of the group to print the total sum of these variables. It's not working right the way i did, so how do i do it?

 

LONG VERSION: :)

1) I have this query:

SELECT p.nume PRODUCT_NAME, p.id PRODUCT_ID, p.pret PRODUCT_PRICE, p.gramaj PRODUCT_WEIGHT,

r.gramaj_mp MP_WEIGHT, mp.nume MP_NAME, mp.pret_desf MP_PRICE

FROM produse p, mat_prime mp, retete r

WHERE p.reteta='true' AND r.id_prod=p.id AND r.id_mp=mp.id

GROUP BY product_name

 

The report has a group with the expression: $F{PRODUCT_NAME}

 

i have a $F{PRODUCT_NAME} inside the group header

 

i can compile and i can run the report with empty datasource, but when i run with a real datasource i get an error (Error filling print... net.sf.jasperreports.engine.JRException: Unknown column name : PRODUCT_NAME)

 

so what's the problem?! why can't i use aliases for column names?

 

I managed to trick it by making a view with the column names where i needed to use aliases and do my report almost how i wanted it. But now i have the following problem:

 

2) i need a column in the detail to be calculated from 2 columns ($F{MP_WEIGHT} and $F{MP_PRICE}). I did this: new Double( ($F{MP_WEIGHT}).doubleValue() * ($F{MP_PRICE}).doubleValue() ) as the variable expression for $V{VALUE}. the $V{VALUE} appear for each row in the group.

Now what i need is the sum of all values of $V{VALUE} in each group to print in the group footer. How do i do that ?!!! I tried using calculation type = sum for this new variable (${TOTAL_PRICE}} but it doesn't work right, the sum is not correct. i also did a $V{TOTAL_PRICE}+$V{VALUE} way, initialising with 0 the TOTAL_PRICE but i get the same result witch is not correct.

 

Please help me !!!!!

Both problems are important!

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

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