Time for action – creating a new report

We will create a new report from scratch. In order to do this, we will need to create the report itself, then create a JDBC-type data set and establish its SQL query. Finally, we will create a general layout, which means we will need to add to our report a series of objects and configure them properly.

  1. We will create a new report and save it under the name, 07_Adding_Parameters.prpt.
  2. We will create the following layout for our report:
    Time for action – creating a new report
  3. At this stage, we need to create a JDBC-type data set, establish the connection with our sakila database, and then create the following query:
    SELECT film.rating, film.title, 
    SUM(payment.amount) AS sum_amount, COUNT(1)  AS count_rental
    FROM payment
    INNER JOIN rental ON rental.rental_id=payment.rental_id
    INNER JOIN inventory ON inventory.inventory_id=rental.inventory_id
    INNER JOIN film ON film.film_id=inventory.film_id
    WHERE film.rating IN ('G','PG','PG-13','R','NC-17')
    AND YEAR(payment.payment_date) = 2005
    AND MONTH(payment_date) = 6
    GROUP BY film.film_id
    ORDER BY film.rating, film.title

    Initially, we will use the default values for film.rating, YEAR(payment.payment_date), and MONTH(payment_date). Later on, we will allow these values to be modified dynamically by the final user.

  4. In the Report Header section, we will place and configure a label to serve as a title. We must configure the Group section so that each new group begins in a new page (Style.pagebreak-after).
  5. In the Group Header section, we will enable and configure a label, a text field, and a rectangle.
  6. In the Details Header section, we will enable and configure three labels.
  7. In the Details section, we need to place and configure two text fields. We will also apply a Row Banding function to this section. We will configure the text field referencing the sum_amount field using the following:
    • Attributes.format = $ #,##0.00;($ #,##0.00)

What just happened?

We created a new report and then added and configured a JDBC-type data set to it. We also defined the layout proposed by this guide. To do so we had to configure the Report Header, Group, Group Header, Details Header, and Details sections.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset