Skip Headers

Oracle Reports Building Reports 10g (9.0.4) Part Number B10602-01 |
Home | Contents | Index

# 5
Building a Tabular Report

#### Figure 5-1 Tabular report output

Text description of the illustration orbrtab_fin.gif

Reports Builder enables you to build many types of reports, such as tabular, form letter, and group above reports. You can learn more about these different types of reports in the Reports Builder online help. This chapter describes the basic elements of a tabular report and how to build a simple tabular report.

#### About tabular reports

A tabular report is the most basic type of report you can build. The report output is organized in a multicolumn, multirow format, with each column corresponding to a column in the database table. In this example, the column labels "Deptno," "Dname," and "Loc," are derived from the columns in your SQL SELECT statement, but you can modify column labels as you wish.

#### Concepts

When you start Oracle Reports, it automatically creates a new report definition, which consists of default settings stored in a report buffer. You create the report you want by customizing this report definition.

##### Data Relationships

- Generally, the first step to define the data Oracle Reports should fetch from the database by creating a query that contains a SELECT statement. Although the report in this section uses only one query, reports can contain any number of queries.

- For each query you create, Oracle Reports automatically creates one default group. The default name of the group is the query name with "G_" prefixed to it. As shown by the data model in the next figure, we've named our query "Q_Department." Therefore, the group created by Oracle Reports for this report is "G_Department." If your query was named "Accounts," the default group name would be "G_Accounts."

- For each database column you specify in the query's SELECT statement, Oracle Reports creates a report column and assigns it to the group. By default, the columns appear in the order in which you enter them in your SELECT statement. The default column names are generated from the database column names or replaced by any aliases specified in your SELECT statement.

- If you select two or more columns with the same name, the first column is given the default name, the second column is given the default name with a "1" appended to it (e.g., "Deptno," "Deptno1"), etc.

##### Layout

- Before you can run your report, you'll need to specify the layout (i.e., the format) of the report output. If you don't, Oracle Reports will fetch the data, but will not display it; you may receive an error message, depending on whether you choose paper or Web layout.

- For this report, you will use the tabular layout style, which is one of eight styles provided by Oracle Reports. The tabular layout displays data in a series of columns running down the page, with the column headings displayed directly above the columns.

#### Example Scenario

In this example, you will use the Report Wizard to build one query to select all of the columns displayed in this report. Oracle Reports will create all other necessary objects (e.g., groups and columns) by default.

To see a sample tabular report, open the examples folder named `tabular`, then open the Oracle Reports example named `tabular.rdf`. For details on how to open it, see "Accessing the example reports" in the Preface.

##### Table 5-1 Features demonstrated in this example

Feature | Location
--- | ---
Use the Report Wizard to create a tabular report with a paper layout. | Section 5.2, "Use the Report Wizard to create a report"

## 5.1 Prerequisites for this example

To build the example in this chapter, you must have access to the sample schema provided with the Oracle9i database. If you don't know if you have access to this sample schema, contact your database administrator. You should have access to the "Human Resources" portion of the schema to complete this example.

## 5.2 Use the Report Wizard to create a report

When you create a report, you can either use the Report Wizard to assist you or create the report yourself. To build the simple report in this example, you can use the Report Wizard. Using the wizard enables you to define the layout for the report, as well as set the data definition.

#### To create a simple report:

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

2. In the Welcome or New Report dialog box, select Use the Report Wizard, then click OK.

3. If the Welcome page displays, click Next.

4. On the Report Type page, select Create Paper Layout Only, then click Next.

5. On the Style page, type a Title for your report, select Tabular, then click Next.

6. On the Data Source page, click SQL Query, then click Next.

7. On the Data page, enter the following SELECT statement in the Data Source definition field:

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

   Tip: This query selects all the department IDs, the department names, the manager IDs, and the location IDs, then sorts the data by the department IDs.

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

1. Click Next.

   Note: If you are not already connected to a database, you will be prompted to connect to the database when you click Next. Ensure that you connect to a database that has the appropriate schema for this example. Section 5.1, "Prerequisites for this example" describes the sample schema requirements for this example.

1. On the Fields page, click the double right arrows (>>) to move all of the fields to the Displayed Fields list, then click Next.

2. On the Totals page, click Next.

3. On the Labels page, click Next.

4. On the Template page, select Predefined Template and click Beige, then click Finish to display your report output in the Paper Design view. It should look something like this:

#### Figure 5-2 Paper Design view for the tabular report

Text description of the illustration orbrtab_fin.gif

Note: In the Paper Design view, you can see how the tabular report displays the data like a table, in order of department ID number.

1. Save the report as tabularreport_<your initials>.rdf.

## 5.3 Summary

Congratulations! You have successfully created a tabular paper report. You now know how to:

- define a tabular report layout using the Report Wizard.

For more information on any of the wizards, views, or properties used in this example, refer to the Reports Builder online help, which you can access in two ways:

- From the Oracle Technology Network (`http://otn.oracle.com/products/reports/`), click Documentation and navigate to the Reports Builder Online Help for the most recent, hosted online help.

- From Reports Builder, choose Help > Help Contents.

  Note: You can replace your Reports Builder online help with the most recent update by downloading the latest online help set available on the Oracle Technology Network (http://otn.oracle.com/docs/products/reports/). Instructions for replacing your help file are included in the readme.txt in the download file.

| Copyright © 2002, 2003 Oracle Corporation. All Rights Reserved. |
Home | Contents | Index