Skip Headers

Oracle® Reports Building Reports 10g Release 2 (10.1.2) B13895-01 |
| Library | Product | Contents | Index

Previous | Next |

# 12 Building an Across Group Report

In this chapter, you will learn about across group reports. By following the steps in this chapter, you can generate the report output shown in Figure 12-1.

Figure 12-1 Across group report output

Description of "Figure 12-1 Across group report output"

Concepts

- Reports Builder enables you to modify the look of your report in multiple ways. In this example, you will build an across group report that prints the values of a database column across the page instead of down.

- In across reports with breaks, the master (or break) group prints "top to bottom"; that is, as it would in other master/detail reports. However, the values in the detail group print across the page, from left to right. When there are more values than will fit on a line, Oracle Reports wraps the line and prints the remaining values across the page on the next line.

- For more information on break reports, refer to the Oracle Reports online Help.

Data Relationships

The break in this report is created through a data link between a master group and a detail query.

Layout

To create the layout used in this report, you will select the master/detail style, then modify the Print Direction setting for one of the groups to ensure it prints across the page instead of down the page.

Example Scenario

As you build this example report, you will:

- Create two queries that select all of the columns displayed, then link them to establish a master/detail relationship

- Create the default layout using the Report Block Wizard.

- Run your report to paper.

To see a sample across report with control breaks, open the examples folder called `acrossbreak`, then open the Oracle Reports example report named `acrossbreak.rdf`. For details on how to open it, see "Accessing the Example Reports" in the Preface.

## 12.1 Prerequisites for this example

To build the example in this chapter, you must have access to the Human Resources sample schema (HR) provided with the Oracle Database. If you do not know if you have access to this sample schema, contact your database administrator.

## 12.2 Create two queries

When you create a report, you can either use the Report Wizard to assist you or create the report yourself. In this example, you will use the Data Model view to create your two queries, then use the tool palette to create a data link between the two queries to relate the data tables.

To create two queries:

1. Launch Reports Builder (or, if already open, choose File > New > Report)

2. In the Welcome or New Report dialog box, select Build a new report manually, then click OK.

3. In the Data Model view that displays, click the SQL Query tool in the tool palette then click in an open area of the Data Model view to display the SQL Query Statement dialog box.

4. In the SQL Query Statement field, enter the following `SELECT` statement:

       SELECT ALL DEPARTMENTS.DEPARTMENT_ID, DEPARTMENTS.DEPARTMENT_NAME,
       DEPARTMENTS.MANAGER_ID, DEPARTMENTS.LOCATION_ID
       FROM DEPARTMENTS

   Note: You can enter this query in any of the following ways: Copy and paste the code from the provided text file called`acrossbreak_code.txt` into the SQL Query Statement field. Click Query Builder to build the query without entering any code manually. Type the code in the SQL Query Statement field.

5. Click OK.

   The data model for your new query displays:

   Figure 12-2 Data Model for Query 1

   Description of "Figure 12-2 Data Model for Query 1"

6. Create another query, this time using the following code:

       SELECT ALL EMPLOYEES.LAST_NAME, EMPLOYEES.FIRST_NAME, EMPLOYEES.DEPARTMENT_ID
       FROM EMPLOYEES
       ORDER BY EMPLOYEES.LAST_NAME

   Note: You can also copy and paste the code from the text file provided in the acrossbreak folder, called `acrossbreak_code.txt`.

7. Click OK.

8. In the Data Model view, click the Data Link tool in the tool palette.

9. Click and drag your mouse from DEPARTMENT_ID column in Q_1, to DEPARTMENT_ID1 in Q_2 to create a data link between the two queries.

   Your data model should now look like this:

   Figure 12-3 Data Model of the two linked queries

   Description of "Figure 12-3 Data Model of the two linked queries"

   Note: You can right-click the data link, then choose Property Inspector from the pop-up menu to ensure that the data link was created properly.

## 12.3 Create the default layout

The steps in this section show you how to use the Report Block Wizard to create the layout and choose how your data will display in your report. Here, you will choose the style of report you want to create, and choose to display the data across the report (hence creating the across group report).

To create the default layout:

1. In the Object Navigator, double-click the Paper Layout node to display the Paper Layout view.

2. In the Paper Layout view, choose Insert > Report Block to display the Report Block Wizard.

3. In the Report Block Wizard, on the Style page, select Group Above, then click Next.

4. On the Groups page:

   - Click G_LAST_NAME in the Available Groups list, then click Across to specify the Print Direction and move this field to the Displayed Groups list.

   - Click G_DEPARTMENT_ID, then click Down.

   - Click Next.

5. On the Fields page, click the right arrow (>) to move the following fields from the Available Fields list to the Displayed Fields list, then click Next:

   - DEPARTMENT_ID

   - DEPARTMENT_NAME

   - LAST_NAME

   - FIRST_NAME

6. On the Labels page, click Next.

7. On the Template page, make sure Beige is selected under Predefined Template, then click Finish to display your report output in the Paper Design view. It should look like this:

Figure 12-4 Paper Layout view for the across group report

Description of "Figure 12-4 Paper Layout view for the across group report"

## 12.4 Run your report to paper

In this section, you will run your report to the Paper Design view so you can see how your report displays.

1. Click the Paper Design button in the toolbar. Your report runs, then displays in the Paper Design view. It should look like the following:

   Figure 12-5 Paper Design View of the Across Group Report

   Description of "Figure 12-5 Paper Design View of the Across Group Report"

2. Save your report as `acrossbreak_``your_initials``.rdf`.

## 12.5 Summary

Congratulations! You have successfully created an across group paper report. You now know how to:

- manually create a data model with two queries.

- create a master/detail report using the Report Block Wizard.

For more information on any of the wizards, views, or properties used in this example, refer to the Oracle Reports online Help, which is available in Reports Builder or hosted on the Oracle Technology Network (OTN), as described in Section 3.1.1, "Using the Oracle Reports online Help".